Repository navigation
Highlights
- Swift 6 language mode. The package now uses tools version 6.0 and Swift 6 strict concurrency.
- Cancellation that works end to end. Cancelling the last caller of
withSingleFlightnow cancels the shared operation and frees its key. - Safer
retry. It runs on the caller's actor and no longer crashes on high attempt counts.
Fixes
retry: exponential backoff saturates instead of trapping once the attempt count reaches 64. The force unwrap is gone, and delays useTask.sleep(for:).withSingleFlight: cancelling one caller no longer affects the others. Cleanup is tied to each flight, so a finishing flight can't remove a newer one that reused its key.AsyncLifetime: finished tasks are removed right away, so long-lived owners no longer accumulate them andcountreflects only live work.AsyncTask: ownership and completion state is protected by a lock, which fixes a race whenbind,storeanddetachedare called from different threads.
Changes
retrytakes anisolation: isolated (any Actor)? = #isolationparameter and runsoperationon the caller's actor. Existing call sites compile unchanged.retryandwithSingleFlightnow accept non-Sendableoperations where the caller's actor allows it.- Dead internal code in
SingleFlightRegistryis removed.
Requirements
- Swift 6.0 or later
- Xcode 16.0 or later
- iOS 16, macOS 13, tvOS 16, watchOS 9
Documentation
- The README has been rewritten. It now has examples with
[weak self]andMainActorhops, and it's correct for Swift 6.
Upgrading from 1.0.0 should need no code changes. Compile after upgrading, since code that called retry with a @Sendable operation or relied on the previous retain behavior may need small updates.