Hi! Is it possible for `CancellableContinuation` t...
# coroutines
g
Hi! Is it possible for
CancellableContinuation
to ignore
onCancellation
argument in its method
Copy code
public fun R: T resume(
    value: R, onCancellation: ((cause: Throwable, value: R, context: CoroutineContext) -> Unit)?
)
when some
CompletionHandler
is set via
Copy code
public fun invokeOnCancellation(handler: CompletionHandler)
? Is it a bug or a feature? I did not find any mention of such behaviour in docs of kotlinx.coroutines. Here is my situation. I wrote my own
Mutex
implementation (just for fun). And I try to debug it with Lincheck. I just tried to add prints in lambdas of both operations like this:
Copy code
continuation.invokeOnCancellation {
    println("invokeOnCancellation!")
    // ...
}
//...
continuation.resume(...) { _, _, _ ->
    println("onCancellation!")
    // ...
}
When I run Lincheck tests, I see only a pile of
invokeOnCancellation!
. No
onCancellation!
is printed. But if comment the only usage of
invokeOnCancellation
then only a pile of
onCancellation!
is printed. So I try to understand what's going on. And it looks to me like an issue above. UPD. No,
CancellableContinuation
does not ignore the argument. It's just some strange things happening in my program. Solved.