Skip to content

Instantly share code, notes, and snippets.

@Alexander-Ignition
Last active September 13, 2022 13:19
Show Gist options
  • Save Alexander-Ignition/d53e390ad7359500f6f13c12c5ce8a22 to your computer and use it in GitHub Desktop.
Save Alexander-Ignition/d53e390ad7359500f6f13c12c5ce8a22 to your computer and use it in GitHub Desktop.
Swift Concurrency

Swift Concurrency

Flavors of tasks

Type Launched by Launchable from Lifetime Cancellation Inherits from origin
async-let tasks async let async functions scoped by statement automatic prioprity, task-local values
Group tasks group.async withTaskGroup scoped by task group automatic prioprity, task-local values
Unstructured tasks Task.init anywhere unscoped Task.cancel() prioprity, task-local values, actor
Detached tasks Task.detached anywhere unscoped Task.cancel() nothing

Presrving the runtime contracts

Swift concurrency: Behind the scenes at 24:40

✅ Safe primitives ⚠️ Caution required 🚫 Unsafe Primitives
await, Actors, Task groups os_unfair_lock, NSLock in synchronus code DispatchSemaphore, pthread_cond, NSCondition, pthread_rw_lock, etc
Compiler enforced No compiler support No compiler support

WWDC

WWDC21

Platforms: iOS 15, macOS 12

WWDC22

Platforms: iOS 16, macOS 13

Conferences

Books

Podcasts

Proposals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment