File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,26 @@ public struct CheckedThrowingContinuation<T> {
242242 fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, throwing \( x) ! \n " )
243243 }
244244 }
245+
246+ /// Resume the task awaiting the continuation by having it either
247+ /// return normally or throw an error based on the state of the given
248+ /// `Result` value.
249+ ///
250+ /// A continuation must be resumed exactly once. If the continuation has
251+ /// already been resumed through this object, then the attempt to resume
252+ /// the continuation again will trap.
253+ ///
254+ /// After `resume` enqueues the task, control is immediately returned to
255+ /// the caller. The task will continue executing when its executor is
256+ /// able to reschedule it.
257+ public func resume< E: Error > ( with x: __owned Result< T , E > ) {
258+ switch x {
259+ case . success( let s) :
260+ return resume ( returning: s)
261+ case . failure( let e) :
262+ return resume ( throwing: e)
263+ }
264+ }
245265}
246266
247267public func withCheckedThrowingContinuation< T> (
You can’t perform that action at this time.
0 commit comments