Skip to content

Commit 6bddba2

Browse files
authored
Merge pull request #35829 from grynspan/main
[Concurrency] Add `*Continuation.resume()` for continuations returning `Void`. This change resolves rdar://74031110.
2 parents 5c7ade3 + ca423f4 commit 6bddba2

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

stdlib/public/Concurrency/CheckedContinuation.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ public struct CheckedContinuation<T> {
151151
}
152152
}
153153

154+
extension CheckedContinuation where T == Void {
155+
/// Resume the task awaiting the continuation by having it return normally
156+
/// from its suspension point.
157+
///
158+
/// A continuation must be resumed exactly once. If the continuation has
159+
/// already been resumed through this object, then the attempt to resume
160+
/// the continuation again will trap.
161+
///
162+
/// After `resume` enqueues the task, control is immediately returned to
163+
/// the caller. The task will continue executing when its executor is
164+
/// able to reschedule it.
165+
@inlinable
166+
public func resume() {
167+
self.resume(returning: ())
168+
}
169+
}
170+
154171
public func withCheckedContinuation<T>(
155172
function: String = #function,
156173
_ body: (CheckedContinuation<T>) -> Void
@@ -264,6 +281,23 @@ public struct CheckedThrowingContinuation<T> {
264281
}
265282
}
266283

284+
extension CheckedThrowingContinuation where T == Void {
285+
/// Resume the task awaiting the continuation by having it return normally
286+
/// from its suspension point.
287+
///
288+
/// A continuation must be resumed exactly once. If the continuation has
289+
/// already been resumed through this object, then the attempt to resume
290+
/// the continuation again will trap.
291+
///
292+
/// After `resume` enqueues the task, control is immediately returned to
293+
/// the caller. The task will continue executing when its executor is
294+
/// able to reschedule it.
295+
@inlinable
296+
public func resume() {
297+
self.resume(returning: ())
298+
}
299+
}
300+
267301
public func withCheckedThrowingContinuation<T>(
268302
function: String = #function,
269303
_ body: (CheckedThrowingContinuation<T>) -> Void

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public struct UnsafeContinuation<T> {
3434
public func resume(returning value: __owned T)
3535
}
3636

37+
extension UnsafeContinuation where T == Void {
38+
@inlinable
39+
public func resume() {
40+
self.resume(returning: ())
41+
}
42+
}
43+
3744
@frozen
3845
public struct UnsafeThrowingContinuation<T> {
3946
@usableFromInline internal var context: Builtin.RawUnsafeContinuation
@@ -58,6 +65,13 @@ public struct UnsafeThrowingContinuation<T> {
5865
}
5966
}
6067

68+
extension UnsafeThrowingContinuation where T == Void {
69+
@inlinable
70+
public func resume() {
71+
self.resume(returning: ())
72+
}
73+
}
74+
6175
#if _runtime(_ObjC)
6276

6377
// Intrinsics used by SILGen to resume or fail continuations

0 commit comments

Comments
 (0)