Skip to content

Commit 8884e3a

Browse files
committed
[SE-0304] Rename Task.suspend() back to Task.yield().
1 parent a12c9eb commit 8884e3a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

stdlib/public/Concurrency/SourceCompatibilityShims.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ extension Task where Success == Never, Failure == Never {
2929
public static func CancellationError() -> _Concurrency.CancellationError {
3030
return _Concurrency.CancellationError()
3131
}
32+
33+
@available(*, deprecated, renamed: "yield()")
34+
@_alwaysEmitIntoClient
35+
public static func suspend() async {
36+
await yield()
37+
}
3238
}
3339

3440
@available(SwiftStdlib 5.5, *)

stdlib/public/Concurrency/Task.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,10 @@ extension Task where Success == Never, Failure == Never {
627627
/// if the task is the highest-priority task in the system, it might go
628628
/// immediately back to executing.
629629
///
630-
@available(*, deprecated, renamed: "suspend()")
630+
/// If this task is the highest-priority task in the system,
631+
/// the executor immediately resumes execution of the same task.
632+
/// As such,
633+
/// this method isn't necessarily a way to avoid resource starvation.
631634
public static func yield() async {
632635
let currentTask = Builtin.getCurrentAsyncTask()
633636
let priority = getJobFlags(currentTask).priority ?? Task.currentPriority._downgradeUserInteractive
@@ -637,11 +640,6 @@ extension Task where Success == Never, Failure == Never {
637640
_enqueueJobGlobal(job)
638641
}
639642
}
640-
641-
@_alwaysEmitIntoClient
642-
public static func suspend() async {
643-
await yield()
644-
}
645643
}
646644

647645
// ==== UnsafeCurrentTask ------------------------------------------------------

0 commit comments

Comments
 (0)