@@ -31,7 +31,7 @@ internal class DispatchedContinuation<in T>(
31
31
* Possible states of reusability:
32
32
*
33
33
* 1) `null`. Cancellable continuation wasn't yet attempted to be reused or
34
- * way used and then invalidated (e.g. because of the cancellation).
34
+ * was used and then invalidated (e.g. because of the cancellation).
35
35
* 2) [CancellableContinuation]. Continuation to be/that is being reused.
36
36
* 3) [REUSABLE_CLAIMED]. CC is currently being reused and its owner executes `suspend` block:
37
37
* ```
@@ -91,7 +91,7 @@ internal class DispatchedContinuation<in T>(
91
91
return state as CancellableContinuationImpl <T >
92
92
}
93
93
}
94
- else -> error(" Inconsistent state $state " )
94
+ else -> error(" Inconsistent state $state " )
95
95
}
96
96
}
97
97
}
@@ -114,13 +114,14 @@ internal class DispatchedContinuation<in T>(
114
114
_reusableCancellableContinuation .loop { state ->
115
115
// not when(state) to avoid Intrinsics.equals call
116
116
when {
117
- state == = REUSABLE_CLAIMED -> if (_reusableCancellableContinuation .compareAndSet(REUSABLE_CLAIMED , continuation)) return null
118
- state == = null -> return null
117
+ state == = REUSABLE_CLAIMED -> {
118
+ if (_reusableCancellableContinuation .compareAndSet(REUSABLE_CLAIMED , continuation)) return null
119
+ }
119
120
state is Throwable -> {
120
121
require(_reusableCancellableContinuation .compareAndSet(state, null ))
121
122
return state
122
123
}
123
- else -> return null // Is not reusable
124
+ else -> error( " Inconsistent state $state " )
124
125
}
125
126
}
126
127
}
0 commit comments