Skip to content

Commit 28f1500

Browse files
committed
Cherry pick Swift 5.5 doc changes in TaskSleep.swift
1 parent 3977d8e commit 28f1500

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

stdlib/public/Concurrency/TaskSleep.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import Swift
1515
@available(SwiftStdlib 5.1, *)
1616
extension Task where Success == Never, Failure == Never {
1717
@available(*, deprecated, renamed: "Task.sleep(nanoseconds:)")
18+
/// Suspends the current task for at least the given duration
19+
/// in nanoseconds.
20+
///
21+
/// This function doesn't block the underlying thread.
1822
public static func sleep(_ duration: UInt64) async {
1923
return await Builtin.withUnsafeContinuation { (continuation: Builtin.RawUnsafeContinuation) -> Void in
2024
let job = _taskCreateNullaryContinuationJob(
@@ -39,10 +43,10 @@ extension Task where Success == Never, Failure == Never {
3943
/// The sleep has finished.
4044
case finished
4145

42-
/// The sleep was cancelled.
46+
/// The sleep was canceled.
4347
case cancelled
4448

45-
/// The sleep was cancelled before it even got started.
49+
/// The sleep was canceled before it even got started.
4650
case cancelledBeforeStarted
4751

4852
/// Decode sleep state from the word of storage.
@@ -100,7 +104,7 @@ extension Task where Success == Never, Failure == Never {
100104
}
101105

102106
/// Called when the sleep(nanoseconds:) operation woke up without being
103-
/// cancelled.
107+
/// canceled.
104108
private static func onSleepWake(
105109
_ wordPtr: UnsafeMutablePointer<Builtin.Word>
106110
) {
@@ -143,7 +147,7 @@ extension Task where Success == Never, Failure == Never {
143147
}
144148
}
145149

146-
/// Called when the sleep(nanoseconds:) operation has been cancelled before
150+
/// Called when the sleep(nanoseconds:) operation has been canceled before
147151
/// the sleep completed.
148152
private static func onSleepCancel(
149153
_ wordPtr: UnsafeMutablePointer<Builtin.Word>
@@ -189,11 +193,13 @@ extension Task where Success == Never, Failure == Never {
189193
}
190194
}
191195

192-
/// Suspends the current task for _at least_ the given duration
193-
/// in nanoseconds, unless the task is cancelled. If the task is cancelled,
194-
/// throws \c CancellationError without waiting for the duration.
196+
/// Suspends the current task for at least the given duration
197+
/// in nanoseconds.
198+
///
199+
/// If the task is canceled before the time ends,
200+
/// this function throws `CancellationError`.
195201
///
196-
/// This function does _not_ block the underlying thread.
202+
/// This function doesn't block the underlying thread.
197203
public static func sleep(nanoseconds duration: UInt64) async throws {
198204
// Allocate storage for the storage word.
199205
let wordPtr = UnsafeMutablePointer<Builtin.Word>.allocate(capacity: 1)

0 commit comments

Comments
 (0)