Skip to content

Commit 424d22c

Browse files
committed
Rename SafeCancellableContinuation to CancellableContinuationImpl
1 parent fb5717a commit 424d22c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public inline suspend fun <T> suspendCancellableCoroutine(
112112
crossinline block: (CancellableContinuation<T>) -> Unit
113113
): T =
114114
suspendCoroutineOrReturn { cont ->
115-
val safe = SafeCancellableContinuation(cont, getParentJobOrAbort(cont))
115+
val safe = CancellableContinuationImpl(cont, getParentJobOrAbort(cont))
116116
if (!holdCancellability) safe.initCancellability()
117117
block(safe)
118118
safe.getResult()
@@ -123,13 +123,13 @@ public inline suspend fun <T> suspendCancellableCoroutine(
123123
@PublishedApi
124124
internal fun getParentJobOrAbort(cont: Continuation<*>): Job? {
125125
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)
127127
if (job != null && !job.isActive) throw job.getCompletionException()
128128
return job
129129
}
130130

131131
@PublishedApi
132-
internal class SafeCancellableContinuation<in T>(
132+
internal class CancellableContinuationImpl<in T>(
133133
private val delegate: Continuation<T>,
134134
private val parentJob: Job?
135135
) : AbstractCoroutine<T>(delegate.context, active = true), CancellableContinuation<T> {
@@ -139,8 +139,8 @@ internal class SafeCancellableContinuation<in T>(
139139
private var decision = UNDECIDED
140140

141141
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")
144144

145145
const val UNDECIDED = 0
146146
const val SUSPENDED = 1
@@ -224,14 +224,14 @@ internal class SafeCancellableContinuation<in T>(
224224
override fun CoroutineDispatcher.resumeUndispatched(value: T) {
225225
val dc = delegate as? DispatchedContinuation ?: throw IllegalArgumentException("Must be used with DispatchedContinuation")
226226
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)
228228
resume(value)
229229
}
230230

231231
override fun CoroutineDispatcher.resumeUndispatchedWithException(exception: Throwable) {
232232
val dc = delegate as? DispatchedContinuation ?: throw IllegalArgumentException("Must be used with DispatchedContinuation")
233233
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)
235235
resumeWithException(exception)
236236
}
237237
}

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Yield.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ package kotlinx.coroutines.experimental
2525
* this function is waiting for dispatching, it resumes with [CancellationException].
2626
*/
2727
suspend fun yield(): Unit = suspendCancellableCoroutine sc@ { cont ->
28-
(cont as SafeCancellableContinuation).resumeYield(Unit)
28+
(cont as CancellableContinuationImpl).resumeYield(Unit)
2929
}

0 commit comments

Comments
 (0)