Rename SUSPENDED_MARKER to COROUTINE_SUSPENDED

This commit is contained in:
Denis Zharkov
2017-01-27 17:29:36 +03:00
parent 246946bc18
commit c362a9154b
123 changed files with 169 additions and 169 deletions
@@ -20,7 +20,7 @@ package kotlin.coroutines.experimental
import java.lang.IllegalStateException
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
import kotlin.coroutines.experimental.intrinsics.SUSPENDED_MARKER
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
import kotlin.coroutines.experimental.jvm.internal.CoroutineImpl
import kotlin.coroutines.experimental.jvm.internal.interceptContinuationIfNeeded
@@ -133,7 +133,7 @@ private inline fun <T> buildContinuationByInvokeCall(
private inline fun processInvokeCallOnCoroutine(completion: Continuation<*>, block: () -> Any?) {
try {
val result = block()
if (result !== SUSPENDED_MARKER) {
if (result !== COROUTINE_SUSPENDED) {
@Suppress("UNCHECKED_CAST")
(completion as Continuation<Any?>).resume(result)
}
@@ -169,7 +169,7 @@ internal class SafeContinuation<in T> @PublishedApi internal constructor(private
val result = this.result // atomic read
when (result) {
UNDECIDED -> if (cas(UNDECIDED, value)) return
SUSPENDED_MARKER -> if (cas(SUSPENDED_MARKER, RESUMED)) {
COROUTINE_SUSPENDED -> if (cas(COROUTINE_SUSPENDED, RESUMED)) {
delegate.resume(value)
return
}
@@ -183,7 +183,7 @@ internal class SafeContinuation<in T> @PublishedApi internal constructor(private
val result = this.result // atomic read
when (result) {
UNDECIDED -> if (cas(UNDECIDED, Fail(exception))) return
SUSPENDED_MARKER -> if (cas(SUSPENDED_MARKER, RESUMED)) {
COROUTINE_SUSPENDED -> if (cas(COROUTINE_SUSPENDED, RESUMED)) {
delegate.resumeWithException(exception)
return
}
@@ -196,13 +196,13 @@ internal class SafeContinuation<in T> @PublishedApi internal constructor(private
internal fun getResult(): Any? {
var result = this.result // atomic read
if (result == UNDECIDED) {
if (cas(UNDECIDED, SUSPENDED_MARKER)) return SUSPENDED_MARKER
if (cas(UNDECIDED, COROUTINE_SUSPENDED)) return COROUTINE_SUSPENDED
result = this.result // reread volatile var
}
when (result) {
RESUMED -> return SUSPENDED_MARKER // already called continuation, indicate SUSPENDED_MARKER upstream
RESUMED -> return COROUTINE_SUSPENDED // already called continuation, indicate COROUTINE_SUSPENDED upstream
is Fail -> throw result.exception
else -> return result // either SUSPENDED_MARKER or data
else -> return result // either COROUTINE_SUSPENDED or data
}
}
}
@@ -131,7 +131,7 @@ private class SequenceBuilderIterator<T> : SequenceBuilder<T>(), Iterator<T>, Co
state = State_Ready
return suspendCoroutineOrReturn { c ->
nextStep = c
SUSPENDED_MARKER
COROUTINE_SUSPENDED
}
}
@@ -141,7 +141,7 @@ private class SequenceBuilderIterator<T> : SequenceBuilder<T>(), Iterator<T>, Co
state = State_ManyReady
return suspendCoroutineOrReturn { c ->
nextStep = c
SUSPENDED_MARKER
COROUTINE_SUSPENDED
}
}
@@ -24,7 +24,7 @@ import kotlin.coroutines.experimental.Continuation
* Obtains the current continuation instance inside suspend functions and either suspend
* currently running coroutine or return result immediately without suspension.
*
* If the [block] returns the special [SUSPENDED_MARKER] value, it means that suspend function did suspend the execution and will
* If the [block] returns the special [COROUTINE_SUSPENDED] value, it means that suspend function did suspend the execution and will
* not return any result immediately. In this case, the [Continuation] provided to the [block] shall be invoked at some moment in the
* future when the result becomes available to resume the computation.
*
@@ -46,5 +46,5 @@ public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Conti
* the execution was suspended and will not return any result immediately.
*/
@SinceKotlin("1.1")
public val SUSPENDED_MARKER: Any = Any()
public val COROUTINE_SUSPENDED: Any = Any()
@@ -21,7 +21,7 @@ import java.lang.IllegalStateException
import kotlin.coroutines.experimental.Continuation
import kotlin.coroutines.experimental.ContinuationInterceptor
import kotlin.coroutines.experimental.CoroutineContext
import kotlin.coroutines.experimental.intrinsics.SUSPENDED_MARKER
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.experimental.jvm.internal.interceptContinuationIfNeeded
import kotlin.jvm.internal.Lambda
@@ -51,7 +51,7 @@ abstract class CoroutineImpl(
override fun resume(value: Any?) {
try {
val result = doResume(value, null)
if (result != SUSPENDED_MARKER)
if (result != COROUTINE_SUSPENDED)
completion!!.resume(result)
} catch (e: Throwable) {
completion!!.resumeWithException(e)
@@ -61,7 +61,7 @@ abstract class CoroutineImpl(
override fun resumeWithException(exception: Throwable) {
try {
val result = doResume(null, exception)
if (result != SUSPENDED_MARKER)
if (result != COROUTINE_SUSPENDED)
completion!!.resume(result)
} catch (e: Throwable) {
completion!!.resumeWithException(e)