fixed runWithCurrentContinuation
This commit is contained in:
committed by
Stanislav Erokhin
parent
85db356611
commit
a70ac0160d
@@ -61,15 +61,19 @@ private val UNDECIDED: Any? = Any()
|
|||||||
private val RESUMED: Any? = Any()
|
private val RESUMED: Any? = Any()
|
||||||
private class Fail(val exception: Throwable)
|
private class Fail(val exception: Throwable)
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
private val RESULT_UPDATER = AtomicReferenceFieldUpdater.newUpdater<SafeContinuation<*>, Any?>(
|
|
||||||
SafeContinuation::class.java, Any::class.java as Class<Any?>, "result")
|
|
||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal class SafeContinuation<T> @PublishedApi internal constructor(private val delegate: Continuation<T>) : Continuation<T> {
|
internal class SafeContinuation<T> @PublishedApi internal constructor(private val delegate: Continuation<T>) : Continuation<T> {
|
||||||
@Volatile
|
@Volatile
|
||||||
private var result: Any? = UNDECIDED
|
private var result: Any? = UNDECIDED
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@JvmStatic
|
||||||
|
private val RESULT_UPDATER = AtomicReferenceFieldUpdater.newUpdater<SafeContinuation<*>, Any?>(
|
||||||
|
SafeContinuation::class.java, Any::class.java as Class<Any?>, "result")
|
||||||
|
}
|
||||||
|
|
||||||
private fun cas(expect: Any?, update: Any?): Boolean =
|
private fun cas(expect: Any?, update: Any?): Boolean =
|
||||||
RESULT_UPDATER.compareAndSet(this, expect, update)
|
RESULT_UPDATER.compareAndSet(this, expect, update)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user