kevin.cianfarini
05/20/2022, 5:36 PMstreetsofboston
05/20/2022, 5:44 PMJoffrey
05/20/2022, 6:05 PMkevin.cianfarini
05/20/2022, 6:26 PMJoffrey
05/20/2022, 6:27 PMWe’re already having to deal with races when our scope is cancelledIn which way?
kevin.cianfarini
05/20/2022, 6:33 PMlaunch
something, and it fails silently. This is a problem only in native for us.
I realize this problem ultimately stems from our poor viewmodel arch. However, it made this bug difficult to track down because there was no indication that the coroutinescope was defunct. Instead, the block
to launch would never get invoked.julian
05/20/2022, 9:06 PMJob.join()
on a job that's part of a structured hierarchy at the root of which is a cancelled scope is not silent. It will throw an exception, if you need that as a signal.Adam Powell
05/20/2022, 10:14 PMjoin
returns when all children have joined, it does not throw an exception if parts of the job hierarchy have failedfinally
blocks to run as the CancellationException
tears it down)julian
05/20/2022, 11:43 PMThis suspending function is cancellable and always checks for a cancellation of the invoking coroutine's Job. If the Job of the invoking coroutine is cancelled or completed when this suspending function is invoked or while it is suspended, this function throws CancellationException.
Joffrey
05/21/2022, 8:19 AMAdam Powell
05/21/2022, 2:15 PMjoin
is cancelled then join
will throw the accompanying CancellationException
- that's standard cancellation on the caller's side. It's not dependent on the job being joined thoughval job = launch { ... }
job.cancel()
doesn't produce an error either