Skip to content

Commit 259c37c

Browse files
committed
[Concurrency] Fix docs which suggested outdated patterns; can't store "current" task safely
1 parent 6c23d92 commit 259c37c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,12 @@ extension Task where Success == Never, Failure == Never {
695695
/// Storing an unsafe reference doesn't affect the task's actual life cycle,
696696
/// and the behavior of accessing an unsafe task reference
697697
/// outside of the `withUnsafeCurrentTask(body:)` method's closure isn't defined.
698-
/// Instead, use the `task` property of `UnsafeCurrentTask`
699-
/// to access an instance of `Task` that you can store long-term
700-
/// and interact with outside of the closure body.
698+
///
699+
/// If necessary to store a `Task` object itself, it is possible to create
700+
/// an un-structured task and store it, however it is not possible to retrieve
701+
/// the "current" task object itself. Instead, interactions with the "current"
702+
/// task are performed with the `currentPriority` and similar APIs which safely
703+
/// query the current task, without exposing its actual identity.
701704
///
702705
/// - Parameters:
703706
/// - body: A closure that takes an `UnsafeCurrentTask` parameter.

0 commit comments

Comments
 (0)