Multi-part atomic remove operation support for LockFreeLinkedList
diff --git a/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Deferred.kt b/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Deferred.kt
index c3954d3..38356b6 100644
--- a/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Deferred.kt
+++ b/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Deferred.kt
@@ -121,14 +121,14 @@
context: CoroutineContext,
active: Boolean
) : AbstractCoroutine<T>(context, active), Deferred<T> {
- override val isCompletedExceptionally: Boolean get() = getState() is CompletedExceptionally
- override val isCancelled: Boolean get() = getState() is Cancelled
+ override val isCompletedExceptionally: Boolean get() = state is CompletedExceptionally
+ override val isCancelled: Boolean get() = state is Cancelled
@Suppress("UNCHECKED_CAST")
suspend override fun await(): T {
// fast-path -- check state (avoid extra object creation)
while(true) { // lock-free loop on state
- val state = this.getState()
+ val state = this.state
if (state !is Incomplete) {
// already complete -- just return result
if (state is CompletedExceptionally) throw state.exception
@@ -143,7 +143,7 @@
@Suppress("UNCHECKED_CAST")
private suspend fun awaitSuspend(): T = suspendCancellableCoroutine { cont ->
cont.unregisterOnCompletion(invokeOnCompletion {
- val state = getState()
+ val state = this.state
check(state !is Incomplete)
if (state is CompletedExceptionally)
cont.resumeWithException(state.exception)
@@ -154,7 +154,7 @@
@Suppress("UNCHECKED_CAST")
override fun getCompleted(): T {
- val state = getState()
+ val state = this.state
check(state !is Incomplete) { "This deferred value has not completed yet" }
if (state is CompletedExceptionally) throw state.exception
return state as T