I don’t quite get it with the docs on `Deferred` F...
# coroutines
p
I don’t quite get it with the docs on
Deferred
For
await
, it says:
[…] If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException. […]
Why would the await function resume with a CancellationException if the job completes while await is waiting?
j
I don't believe the current coroutine could complete normally if it is suspended on
await
anyway. But it's indeed a bit confusing that they mention "completed" as an option here 🤔
n
You can switch to a
CompletableJob
using
withContext
and complete it while
await
is called. Edit: had a play link here, but mistyped it so it was inaccurate.
Actually what I see is that it seems to hang: https://pl.kotl.in/smVAW6ofz
1
p
Aaah I think I just had a blackout and oversaw that it affects the current coroutines