@@ -252,17 +252,32 @@ extension CheckedContinuation {
252
252
}
253
253
}
254
254
255
- /// Invokes the passed in closure and provides with a checked continuation for the current task.
255
+ /// Invokes the passed in closure with a checked continuation for the current task.
256
+ ///
256
257
/// The body of the closure executes synchronously on the calling task, and once it returns
257
258
/// the calling task is suspended. It is possible to immediately resume the task, or escape the
258
- /// continuation in order to complete it afterwards, and thus resuming the suspended task.
259
+ /// continuation in order to complete it afterwards, which will them resume suspended task.
260
+ ///
261
+ /// You must invoke the continuation's `resume` method exactly once.
262
+ ///
263
+ /// Missing to invoke it (eventually) will cause the calling task to remain suspended
264
+ /// indefinitely which will result in the task "hanging" as well as being leaked with
265
+ /// no possibility to destroy it.
266
+ ///
267
+ /// The checked continuation offers detection of mis-use, and dropping the last reference
268
+ /// to it, without having resumed it will trigger a warning. Resuming a continuation twice
269
+ /// is also diagnosed and will cause a crash.
259
270
///
260
271
/// - Parameters:
261
272
/// - function: A string identifying the declaration that is the notional
262
273
/// source for the continuation, used to identify the continuation in
263
274
/// runtime diagnostics related to misuse of this continuation.
264
275
/// - body: A closure that takes a `CheckedContinuation` parameter.
265
- /// You must resume the continuation exactly once.
276
+ /// - Returns: The value continuation is resumed with.
277
+ ///
278
+ /// - SeeAlso: `withCheckedThrowingContinuation(function:_:)`
279
+ /// - SeeAlso: `withUnsafeContinuation(function:_:)`
280
+ /// - SeeAlso: `withUnsafeThrowingContinuation(function:_:)`
266
281
@available ( SwiftStdlib 5 . 1 , * )
267
282
@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
268
283
@inlinable
@@ -275,20 +290,34 @@ public func withCheckedContinuation<T>(
275
290
}
276
291
}
277
292
278
- /// Invokes the passed in closure and provides with a checked throwing continuation for the current task.
293
+ /// Invokes the passed in closure with a checked continuation for the current task.
294
+ ///
279
295
/// The body of the closure executes synchronously on the calling task, and once it returns
280
296
/// the calling task is suspended. It is possible to immediately resume the task, or escape the
281
- /// continuation in order to complete it afterwards, and thus resuming the suspended task.
297
+ /// continuation in order to complete it afterwards, which will them resume suspended task.
298
+ ///
299
+ /// If `resume(throwing:)` is called on the continuation, this function throws that error.
300
+ ///
301
+ /// You must invoke the continuation's `resume` method exactly once.
302
+ ///
303
+ /// Missing to invoke it (eventually) will cause the calling task to remain suspended
304
+ /// indefinitely which will result in the task "hanging" as well as being leaked with
305
+ /// no possibility to destroy it.
306
+ ///
307
+ /// The checked continuation offers detection of mis-use, and dropping the last reference
308
+ /// to it, without having resumed it will trigger a warning. Resuming a continuation twice
309
+ /// is also diagnosed and will cause a crash.
282
310
///
283
311
/// - Parameters:
284
312
/// - function: A string identifying the declaration that is the notional
285
313
/// source for the continuation, used to identify the continuation in
286
314
/// runtime diagnostics related to misuse of this continuation.
287
315
/// - body: A closure that takes a `CheckedContinuation` parameter.
288
- /// You must resume the continuation exactly once .
316
+ /// - Returns: The value continuation is resumed with .
289
317
///
290
- /// If `resume(throwing:)` is called on the continuation,
291
- /// this function throws that error.
318
+ /// - SeeAlso: `withCheckedContinuation(function:_:)`
319
+ /// - SeeAlso: `withUnsafeContinuation(function:_:)`
320
+ /// - SeeAlso: `withUnsafeThrowingContinuation(function:_:)`
292
321
@available ( SwiftStdlib 5 . 1 , * )
293
322
@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
294
323
@inlinable
0 commit comments