Hi everyone, I have a question about the documenta...
# coroutines
p
Hi everyone, I have a question about the documentation on `suspendCancellableCoroutine`: The documentation states: “This function throws a CancellationException if the Job of the coroutine is cancelled or completed while it is suspended.” Could you explain me how it’s possible to complete the Job while it’s suspended?
s
🤔 sounds to me like it should be impossible. A coroutine's job only completes when its code finishes running. If the code's suspended, then by definition it's not finished. Perhaps that wording in the documentation is outdated, or just imprecise...
(a coroutine can certainly be cancelled while it's suspended, but I don't think that's the part you were querying)
p
That’s indeed what I thought too. But I’m a little new to coroutines, that’s why I was not sure 🤔
e
cancellation is only observed at cancellation points
hmm. actually rereading I'm not sure what the documentation is aiming to describe either
s
Very odd wording indeed. Unlike cancellation, a coroutine "completes" itself, not "_is_ completed" by something else....
k
The only case I can possibly think about is
CompletableDeferred