Skip to content

AsyncGuardKit 1.1.0

Latest

Choose a tag to compare

@ANSCoder ANSCoder released this 27 Oct 15:36
5cb33ab

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 withSingleFlight now 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 use Task.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 and count reflects only live work.
  • AsyncTask: ownership and completion state is protected by a lock, which fixes a race when bind, store and detached are called from different threads.

Changes

  • retry takes an isolation: isolated (any Actor)? = #isolation parameter and runs operation on the caller's actor. Existing call sites compile unchanged.
  • retry and withSingleFlight now accept non-Sendable operations where the caller's actor allows it.
  • Dead internal code in SingleFlightRegistry is 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] and MainActor hops, 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.