Skip to content

[Concurrency] Deprecate Task.current and instance properties #37025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stdlib/public/Concurrency/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extension Task {
/// this function was called.
///
/// All functions available on the Task
@available(*, deprecated, message: "`Task.current` has been deprecated and will be removed, use static functions on Task instead.")
public static var current: Task? {
guard let _task = _getCurrentAsyncTask() else {
return nil
Expand Down Expand Up @@ -88,6 +89,7 @@ extension Task {
///
/// - SeeAlso: `Task.Priority`
/// - SeeAlso: `Task.currentPriority`
@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.")
public var priority: Priority {
getJobFlags(_task).priority
}
Expand Down Expand Up @@ -158,6 +160,7 @@ extension Task {
}

/// Returns the `Task` that this handle refers to.
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon.")
public var task: Task {
Task(_task)
}
Expand Down Expand Up @@ -671,6 +674,7 @@ public struct UnsafeCurrentTask {
///
/// Operations on `Task` (unlike `UnsafeCurrentTask`) are safe to be called
/// from any other task (or thread).
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon.")
public var task: Task {
Task(_task)
}
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/Concurrency/TaskCancellation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ extension Task {
/// Returns `true` if the task is cancelled, and should stop executing.
///
/// - SeeAlso: `checkCancellation()`
@available(*, deprecated, message: "Storing `Task` instances has been deprecated and will be removed soon. Use the static 'Task.isCancelled' instead.")
public var isCancelled: Bool {
_taskIsCancelled(_task)
}
Expand Down