Skip to content

Commit e71a885

Browse files
committed
[Concurrency] Deprecate Task.current and instance properties
1 parent 623e54f commit e71a885

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extension Task {
5050
/// this function was called.
5151
///
5252
/// All functions available on the Task
53+
@available(*, deprecated, message: "`Task.current` has been deprecated and will be removed, use static functions on Task instead.")
5354
public static var current: Task? {
5455
guard let _task = _getCurrentAsyncTask() else {
5556
return nil
@@ -88,6 +89,7 @@ extension Task {
8889
///
8990
/// - SeeAlso: `Task.Priority`
9091
/// - SeeAlso: `Task.currentPriority`
92+
@available(*, deprecated, message: "Storing `Task` instances has been deprecated, and as such instance functions on Task are deprecated and will be removed soon. Use the static 'Task.currentPriority' instead.")
9193
public var priority: Priority {
9294
getJobFlags(_task).priority
9395
}
@@ -158,6 +160,7 @@ extension Task {
158160
}
159161

160162
/// Returns the `Task` that this handle refers to.
163+
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon.")
161164
public var task: Task {
162165
Task(_task)
163166
}
@@ -671,6 +674,7 @@ public struct UnsafeCurrentTask {
671674
///
672675
/// Operations on `Task` (unlike `UnsafeCurrentTask`) are safe to be called
673676
/// from any other task (or thread).
677+
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon.")
674678
public var task: Task {
675679
Task(_task)
676680
}

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extension Task {
6464
/// Returns `true` if the task is cancelled, and should stop executing.
6565
///
6666
/// - SeeAlso: `checkCancellation()`
67+
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon. Use the static 'Task.isCancelled' instead.")
6768
public var isCancelled: Bool {
6869
_taskIsCancelled(_task)
6970
}

0 commit comments

Comments
 (0)