@@ -186,15 +186,14 @@ internal class DispatchedContinuation<in T>(
186
186
get() = this
187
187
188
188
override fun resumeWith (result : Result <T >) {
189
- val context = continuation.context
190
189
val state = result.toState()
191
190
if (dispatcher.isDispatchNeeded(context)) {
192
191
_state = state
193
192
resumeMode = MODE_ATOMIC
194
193
dispatcher.dispatch(context, this )
195
194
} else {
196
195
executeUnconfined(state, MODE_ATOMIC ) {
197
- withCoroutineContext(this . context, countOrElement) {
196
+ withCoroutineContext(context, countOrElement) {
198
197
continuation.resumeWith(result)
199
198
}
200
199
}
@@ -204,11 +203,8 @@ internal class DispatchedContinuation<in T>(
204
203
// We inline it to save an entry on the stack in cases where it shows (unconfined dispatcher)
205
204
// It is used only in Continuation<T>.resumeCancellableWith
206
205
@Suppress(" NOTHING_TO_INLINE" )
207
- internal inline fun resumeCancellableWith (
208
- result : Result <T >,
209
- noinline onCancellation : ((cause: Throwable ) -> Unit )?
210
- ) {
211
- val state = result.toState(onCancellation)
206
+ internal inline fun resumeCancellableWith (result : Result <T >) {
207
+ val state = result.toState()
212
208
if (dispatcher.isDispatchNeeded(context)) {
213
209
_state = state
214
210
resumeMode = MODE_CANCELLABLE
@@ -222,15 +218,6 @@ internal class DispatchedContinuation<in T>(
222
218
}
223
219
}
224
220
225
- // takeState had already cleared the state so we cancel takenState here
226
- override fun cancelCompletedResult (takenState : Any? , cause : Throwable ) {
227
- // It is Ok to call onCancellation here without try/catch around it, since this function only faces
228
- // a "bound" cancellation handler that performs the safe call to the user-specified code.
229
- if (takenState is CompletedWithCancellation ) {
230
- takenState.onCancellation(cause)
231
- }
232
- }
233
-
234
221
// inline here is to save us an entry on the stack for the sake of better stacktraces
235
222
@Suppress(" NOTHING_TO_INLINE" )
236
223
internal inline fun resumeCancelled (state : Any? ): Boolean {
@@ -271,9 +258,8 @@ internal class DispatchedContinuation<in T>(
271
258
@InternalCoroutinesApi
272
259
public fun <T > Continuation<T>.resumeCancellableWith (
273
260
result : Result <T >,
274
- onCancellation : ((cause: Throwable ) -> Unit )? = null
275
261
): Unit = when (this ) {
276
- is DispatchedContinuation -> resumeCancellableWith(result, onCancellation )
262
+ is DispatchedContinuation -> resumeCancellableWith(result)
277
263
else -> resumeWith(result)
278
264
}
279
265
0 commit comments