You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementation-independent extensions
Remove and encapsulate parts of JobSupport
Assert invariants in AbstractContinuation
Use separate code path for Cancelling state
Copy file name to clipboardExpand all lines: common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/AbstractContinuation.kt
+41-44
Original file line number
Diff line number
Diff line change
@@ -104,7 +104,7 @@ internal abstract class AbstractContinuation<in T>(
104
104
val handle = parent.invokeOnCompletion(onCancelling =true, handler =ChildContinuation(parent, this).asHandler)
105
105
106
106
parentHandle = handle
107
-
// now check our state _after_ registering (see updateState order of actions)
107
+
// now check our state _after_ registering (see updateStateToFinal order of actions)
108
108
if (isCompleted) {
109
109
handle.dispose()
110
110
parentHandle =NonDisposableHandle// release it just in case, to aid GC
@@ -117,7 +117,7 @@ internal abstract class AbstractContinuation<in T>(
117
117
loopOnState { state ->
118
118
if (state !isNotCompleted) returnfalse// quit if already complete
119
119
if (state isCancelling) returnfalse// someone else succeeded
120
-
if (updateStateCancelled(state, cause)) returntrue
120
+
if (tryCancel(state, cause)) returntrue
121
121
}
122
122
}
123
123
@@ -170,8 +170,8 @@ internal abstract class AbstractContinuation<in T>(
170
170
isCancelledContinuation-> {
171
171
/*
172
172
* Continuation is complete, invoke directly.
173
-
* NOTE: multiple invokeOnCancellation calls with different handlers are allowed on completed coroutine.
174
-
* It's slightly inconsistent with running coroutine, but currently, we have no mechanism to check
173
+
* NOTE: multiple invokeOnCancellation calls with different handlers are allowed on cancelled continuation.
174
+
* It's inconsistent with running continuation, but currently, we have no mechanism to check
175
175
* whether any handler was registered during continuation lifecycle without additional overhead.
176
176
* This may be changed in the future.
177
177
*
@@ -181,19 +181,28 @@ internal abstract class AbstractContinuation<in T>(
Copy file name to clipboardExpand all lines: common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt
0 commit comments