Skip to content

[SE-0304] Rename Task.suspend() back to Task.yield(). #38654

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
Jul 27, 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
6 changes: 6 additions & 0 deletions stdlib/public/Concurrency/SourceCompatibilityShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ extension Task where Success == Never, Failure == Never {
public static func CancellationError() -> _Concurrency.CancellationError {
return _Concurrency.CancellationError()
}

@available(*, deprecated, renamed: "yield()")
@_alwaysEmitIntoClient
public static func suspend() async {
await yield()
}
}

@available(SwiftStdlib 5.5, *)
Expand Down
10 changes: 4 additions & 6 deletions stdlib/public/Concurrency/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,10 @@ extension Task where Success == Never, Failure == Never {
/// if the task is the highest-priority task in the system, it might go
/// immediately back to executing.
///
@available(*, deprecated, renamed: "suspend()")
/// If this task is the highest-priority task in the system,
/// the executor immediately resumes execution of the same task.
/// As such,
/// this method isn't necessarily a way to avoid resource starvation.
public static func yield() async {
let currentTask = Builtin.getCurrentAsyncTask()
let priority = getJobFlags(currentTask).priority ?? Task.currentPriority._downgradeUserInteractive
Expand All @@ -637,11 +640,6 @@ extension Task where Success == Never, Failure == Never {
_enqueueJobGlobal(job)
}
}

@_alwaysEmitIntoClient
public static func suspend() async {
await yield()
}
}

// ==== UnsafeCurrentTask ------------------------------------------------------
Expand Down