• Stars
    star
    1,099
  • Rank 42,192 (Top 0.9 %)
  • Language
    Swift
  • License
    BSD 3-Clause "New...
  • Created about 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Practical solutions to problems with Swift Concurrency

ConcurrencyRecipes

Practical solutions to problems with Swift Concurrency

Swift Concurrency can be really hard to use. I thought it could be handy to document and share solutions and hazards you might face along the way. I am absolutely not saying this is comprehensive, or that the solutions presented are great. I'm learning too. Contributions are very welcome, especially for problems!

Hazards

Quick definitions for the hazards referenced throughout the recipes:

  • Timing: More than one option is available, but can affect when events actually occur.
  • Ordering: Unstructured tasks means ordering is up to the caller. Think carefully about dependencies, multiple invocations, and cancellation.
  • Lack of Caller Control: definitions always control actor context. This is different from other threading models, and you cannot alter definitions you do not control.
  • Sendability: types that cross isolation domains must be sendable. This isn't always easy, and for types you do not control, not possible.
  • Blocking: Swift concurrency uses a fixed-size thread pool. Tying up background threads can lead lag and even deadlock.
  • Availability: Concurrency is evolving rapidly, and some APIs require the latest SDK.
  • Async virality: Making a function async affects all its callsites. This can result in a large number of changes, each of which could, itself, affect subsequence callsites.
  • Actor Reentrancy: More than one thread can enter an Actor's async methods. An actor's state can change across awaits.

Table of Contents

Contributing and Collaboration

I'd love to hear from you! Get in touch via mastodon, an issue, or a pull request.

I prefer collaboration, and would love to find ways to work together if you have a similar project.

By participating in this project you agree to abide by the Contributor Code of Conduct.

More Repositories

1

Queue

A queue for Swift concurrency
Swift
246
star
2

MainOffender

Utilities for transitioning to Swift Concurrency
Swift
131
star
3

XCLint

Xcode project linting
Swift
90
star
4

TextEditingReference

A non-curated collection of tools for working with text on Apple platforms
78
star
5

kernel-tutorial

A step-by-step tutorial for building a simple kernel
C
65
star
6

Empire

A local persistence system for Swift
Swift
65
star
7

nsui

AppKit and UIKit without conditional compilation
Swift
56
star
8

PackageTemplate

A template for Swift packages on GitHub
Swift
54
star
9

Lock

A lock for Swift concurrency
Swift
38
star
10

AppTemplate

A template for setting up targets within Xcode
Swift
28
star
11

Packet

AsyncSequence Data transforms
Swift
26
star
12

swift-passkeys

An experiment building passkey-based auth with Swift and AWS
Swift
17
star
13

three

Three Programming Language
C++
8
star
14

Nero

A watchOS app to help you care for aquariums
Swift
6
star
15

TaskProgress

A progress mechanism for Swift Concurrency
5
star
16

XCConfig

xcconfig file parsing and evaluation
Swift
4
star
17

rake-file-content

Ruby rake file tasks with content-based dependencies
Ruby
3
star
18

swift-keyspaces

An experiment connecting Swift to AWS Keyspaces (Cassandra)
Swift
2
star
19

cosl

Collaborative Open Source License
2
star
20

config

dot files and configuration
Shell
2
star
21

OAuthenticator

Lightweight OAuth 2.0 request authentication in Swift
1
star
22

rake-compile

A set of Rake DSL extensions for compiling native code
Ruby
1
star
23

rake-multifile

Rake file task with automatic parallel dependencies
Ruby
1
star
24

vex

Makefile
1
star
25

osin-cassandra-store

Cassandra storage for the OSIN Go Oauth library
Go
1
star
26

rake-remote-file

Ruby Rake extension to support remote file task
Ruby
1
star
27

vex-generator

Rust
1
star
28

c-dependecies

Manage C/C++ file dependencies with Ruby
Ruby
1
star