Skip to content

Commit db6eeb9

Browse files
ktosoamartini51
andauthored
[Concurrency] Fix docs which suggested outdated patterns; can't store "current" task safely (#41312)
Co-authored-by: Alex Martini <[email protected]> Co-authored-by: Alex Martini <[email protected]>
1 parent f698c3f commit db6eeb9

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
@@ -681,9 +681,12 @@ extension Task where Success == Never, Failure == Never {
681681
/// Storing an unsafe reference doesn't affect the task's actual life cycle,
682682
/// and the behavior of accessing an unsafe task reference
683683
/// outside of the `withUnsafeCurrentTask(body:)` method's closure isn't defined.
684-
/// Instead, use the `task` property of `UnsafeCurrentTask`
685-
/// to access an instance of `Task` that you can store long-term
686-
/// and interact with outside of the closure body.
684+
/// There's no safe way to retrieve a reference to the current task
685+
/// and save it for long-term use.
686+
/// To query the current task without saving a reference to it,
687+
/// use properties like `currentPriority`.
688+
/// If you need to store a reference to a task,
689+
/// create an unstructured task using `Task.detached(priority:operation:)` instead.
687690
///
688691
/// - Parameters:
689692
/// - body: A closure that takes an `UnsafeCurrentTask` parameter.

0 commit comments

Comments
 (0)