@@ -112,7 +112,7 @@ public inline suspend fun <T> suspendCancellableCoroutine(
112
112
crossinline block : (CancellableContinuation <T >) -> Unit
113
113
): T =
114
114
suspendCoroutineOrReturn { cont ->
115
- val safe = SafeCancellableContinuation (cont, getParentJobOrAbort(cont))
115
+ val safe = CancellableContinuationImpl (cont, getParentJobOrAbort(cont))
116
116
if (! holdCancellability) safe.initCancellability()
117
117
block(safe)
118
118
safe.getResult()
@@ -123,13 +123,13 @@ public inline suspend fun <T> suspendCancellableCoroutine(
123
123
@PublishedApi
124
124
internal fun getParentJobOrAbort (cont : Continuation <* >): Job ? {
125
125
val job = cont.context[Job ]
126
- // fast path when parent job is already complete (we don't even construct SafeCancellableContinuation object)
126
+ // fast path when parent job is already complete (we don't even construct CancellableContinuationImpl object)
127
127
if (job != null && ! job.isActive) throw job.getCompletionException()
128
128
return job
129
129
}
130
130
131
131
@PublishedApi
132
- internal class SafeCancellableContinuation <in T >(
132
+ internal class CancellableContinuationImpl <in T >(
133
133
private val delegate : Continuation <T >,
134
134
private val parentJob : Job ?
135
135
) : AbstractCoroutine<T>(delegate.context, active = true ), CancellableContinuation<T> {
@@ -139,8 +139,8 @@ internal class SafeCancellableContinuation<in T>(
139
139
private var decision = UNDECIDED
140
140
141
141
private companion object {
142
- val DECISION : AtomicIntegerFieldUpdater <SafeCancellableContinuation <* >> =
143
- AtomicIntegerFieldUpdater .newUpdater(SafeCancellableContinuation ::class .java, " decision" )
142
+ val DECISION : AtomicIntegerFieldUpdater <CancellableContinuationImpl <* >> =
143
+ AtomicIntegerFieldUpdater .newUpdater(CancellableContinuationImpl ::class .java, " decision" )
144
144
145
145
const val UNDECIDED = 0
146
146
const val SUSPENDED = 1
@@ -224,14 +224,14 @@ internal class SafeCancellableContinuation<in T>(
224
224
override fun CoroutineDispatcher.resumeUndispatched (value : T ) {
225
225
val dc = delegate as ? DispatchedContinuation ? : throw IllegalArgumentException (" Must be used with DispatchedContinuation" )
226
226
check(dc.dispatcher == = this ) { " Must be invoked from the context CoroutineDispatcher" }
227
- DECISION .compareAndSet(this @SafeCancellableContinuation , SUSPENDED , UNDISPATCHED )
227
+ DECISION .compareAndSet(this @CancellableContinuationImpl , SUSPENDED , UNDISPATCHED )
228
228
resume(value)
229
229
}
230
230
231
231
override fun CoroutineDispatcher.resumeUndispatchedWithException (exception : Throwable ) {
232
232
val dc = delegate as ? DispatchedContinuation ? : throw IllegalArgumentException (" Must be used with DispatchedContinuation" )
233
233
check(dc.dispatcher == = this ) { " Must be invoked from the context CoroutineDispatcher" }
234
- DECISION .compareAndSet(this @SafeCancellableContinuation , SUSPENDED , UNDISPATCHED )
234
+ DECISION .compareAndSet(this @CancellableContinuationImpl , SUSPENDED , UNDISPATCHED )
235
235
resumeWithException(exception)
236
236
}
237
237
}
0 commit comments