File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ import kotlin.coroutines.suspendCoroutine
13
13
* If the cancel reason was not a [CancellationException], then the original exception is added as cause of the
14
14
* [CancellationException] that this continuation resumes with.
15
15
*/
16
- public interface CancellableContinuation <in T > : Continuation <T >, Job
16
+ public interface CancellableContinuation <in T > : Continuation <T >, Job {
17
+ /* *
18
+ * Returns `true` if this continuation was cancelled. It implies that [isActive] is `false`.
19
+ */
20
+ val isCancelled: Boolean
21
+ }
17
22
18
23
/* *
19
24
* Suspend coroutine similar to [suspendCoroutine], but provide an implementation of [CancellableContinuation] to
@@ -56,6 +61,9 @@ internal class SafeCancellableContinuation<in T>(
56
61
return state
57
62
}
58
63
64
+ override val isCancelled: Boolean
65
+ get() = getState() is Cancelled
66
+
59
67
@Suppress(" UNCHECKED_CAST" )
60
68
override fun afterCompletion (state : Any? ) {
61
69
if (suspendedThread == = Thread .currentThread()) {
You can’t perform that action at this time.
0 commit comments