Skip to content

Commit 9f70da0

Browse files
authored
Merge pull request swiftlang#67457 from mikeash/task-cancellation-deadlock-docs
[Concurrency] Warn about deadlock potential in withTaskCancellationHandler docs.
2 parents 994d30a + 1c86195 commit 9f70da0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ import Swift
2424
/// operation is running code that never checks for cancellation, a cancellation
2525
/// handler still runs and provides a chance to run some cleanup code.
2626
///
27+
/// Cancellation handlers which acquire locks must take care to avoid deadlock.
28+
/// The cancellation handler may be invoked while holding internal locks
29+
/// associated with the task or other tasks. Other operations on the task, such
30+
/// as resuming a continuation, may acquire these same internal locks.
31+
/// Therefore, if a cancellation handler must acquire a lock, other code should
32+
/// not cancel tasks or resume continuations while holding that lock.
33+
///
2734
/// Doesn't check for cancellation, and always executes the passed `operation`.
2835
///
2936
/// The `operation` executes on the calling execution context and does not suspend by itself,

0 commit comments

Comments
 (0)