• Stars
    star
    699
  • Rank 62,121 (Top 2 %)
  • Language
    Swift
  • License
    BSD 3-Clause "New...
  • Created 5 months ago
  • Updated about 1 month 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
187
star
2

MainOffender

Utilities for transitioning to Swift Concurrency
Swift
92
star
3

XCLint

Xcode project linting
Swift
75
star
4

kernel-tutorial

A step-by-step tutorial for building a simple kernel
C
59
star
5

nsui

AppKit and UIKit without conditional compilation
Swift
42
star
6

TextEditingReference

A non-curated collection of tools for working with text on Apple platforms
42
star
7

PackageTemplate

A template for Swift packages on GitHub
Swift
38
star
8

AppTemplate

A template for setting up targets within Xcode
Swift
26
star
9

swift-passkeys

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

three

Three Programming Language
C++
6
star
11

XCConfig

xcconfig file parsing and evaluation
Swift
4
star
12

rake-file-content

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

swift-keyspaces

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

cosl

Collaborative Open Source License
2
star
15

config

dot files and configuration
Shell
2
star
16

OAuthenticator

Lightweight OAuth 2.0 request authentication in Swift
1
star
17

rake-multifile

Rake file task with automatic parallel dependencies
Ruby
1
star
18

rake-compile

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

vex

Makefile
1
star
20

osin-cassandra-store

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

vex-generator

Rust
1
star
22

rake-remote-file

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

c-dependecies

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

Packet

AsyncSequence Data transforms
Swift
1
star