@@ -68,11 +68,11 @@ internal final class CheckedContinuationCanary {
68
68
69
69
internal func takeContinuation< T> ( ) -> UnsafeContinuation < T > ? {
70
70
return unsafeBitCast ( _takeContinuation ( ) ,
71
- to: UnsafeContinuation< T> . self )
71
+ to: UnsafeContinuation< T>? . self )
72
72
}
73
73
internal func takeThrowingContinuation< T> ( ) -> UnsafeThrowingContinuation < T > ? {
74
74
return unsafeBitCast ( _takeContinuation ( ) ,
75
- to: UnsafeThrowingContinuation< T> . self )
75
+ to: UnsafeThrowingContinuation< T>? . self )
76
76
}
77
77
78
78
deinit {
@@ -137,12 +137,16 @@ public struct CheckedContinuation<T> {
137
137
///
138
138
/// A continuation must be resumed exactly once. If the continuation has
139
139
/// already been resumed through this object, then the attempt to resume
140
- /// the continuation again will be logged, but otherwise have no effect.
140
+ /// the continuation again will trap.
141
+ ///
142
+ /// After `resume` enqueues the task, control is immediately returned to
143
+ /// the caller. The task will continue executing when its executor is
144
+ /// able to reschedule it.
141
145
public func resume( returning x: __owned T) {
142
146
if let c: UnsafeContinuation < T > = canary. takeContinuation ( ) {
143
147
c. resume ( returning: x)
144
148
} else {
145
- logFailedCheck ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, returning \( x) ! \n " )
149
+ fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, returning \( x) ! \n " )
146
150
}
147
151
}
148
152
}
@@ -207,29 +211,35 @@ public struct CheckedThrowingContinuation<T> {
207
211
/// from its suspension point.
208
212
///
209
213
/// A continuation must be resumed exactly once. If the continuation has
210
- /// already been resumed through this object, whether by `resume(returning:)`
211
- /// or by `resume(throwing:)`, then the attempt to resume
212
- /// the continuation again will be logged, but otherwise have no effect.
214
+ /// already been resumed through this object, then the attempt to resume
215
+ /// the continuation again will trap.
216
+ ///
217
+ /// After `resume` enqueues the task, control is immediately returned to
218
+ /// the caller. The task will continue executing when its executor is
219
+ /// able to reschedule it.
213
220
public func resume( returning x: __owned T) {
214
221
if let c: UnsafeThrowingContinuation < T > = canary. takeThrowingContinuation ( ) {
215
222
c. resume ( returning: x)
216
223
} else {
217
- logFailedCheck ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, returning \( x) ! \n " )
224
+ fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, returning \( x) ! \n " )
218
225
}
219
226
}
220
227
221
228
/// Resume the task awaiting the continuation by having it throw an error
222
229
/// from its suspension point.
223
230
///
224
231
/// A continuation must be resumed exactly once. If the continuation has
225
- /// already been resumed through this object, whether by `resume(returning:)`
226
- /// or by `resume(throwing:)`, then the attempt to resume
227
- /// the continuation again will be logged, but otherwise have no effect.
232
+ /// already been resumed through this object, then the attempt to resume
233
+ /// the continuation again will trap.
234
+ ///
235
+ /// After `resume` enqueues the task, control is immediately returned to
236
+ /// the caller. The task will continue executing when its executor is
237
+ /// able to reschedule it.
228
238
public func resume( throwing x: __owned Error) {
229
239
if let c: UnsafeThrowingContinuation < T > = canary. takeThrowingContinuation ( ) {
230
240
c. resume ( throwing: x)
231
241
} else {
232
- logFailedCheck ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, throwing \( x) ! \n " )
242
+ fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, throwing \( x) ! \n " )
233
243
}
234
244
}
235
245
}
0 commit comments