Skip to content

2.0.1

Latest

Choose a tag to compare

@dfed dfed released this 20 Nov 01:31
c65d55b

Fixes a deadlock that can happen when you enqueue a task while holding a lock that the task's operation also takes in a priority escalation handler.

Fixes

  • Task(on:) no longer runs the new task's priority escalation handlers on the thread that enqueues it. On macOS/iOS/tvOS/watchOS/visionOS 26+ and Linux, this used to happen when the task began its operation before Task(on:) returned and a higher-priority task was already waiting behind it. Task(on:) then escalated the task in place and ran its withTaskPriorityEscalationHandler(operation:onPriorityEscalated:) handler on the enqueueing thread. That deadlocked if the enqueueing code held a lock the handler also takes, and could deadlock when enqueueing from a cancellation handler. Now Task(on:) escalates the task from a new task, and the task also raises its own priority as its turn begins, so it still takes its turn at the escalated priority. (#106)

Other

  • Main-actor tests check the main dispatch queue instead of Thread.isMainThread, and the Linux CI job also runs the tests in debug. (#105)

Full Changelog: 2.0.0...2.0.1