Good morning. First time writing here, sorry if I ...
# coroutines
c
Good morning. First time writing here, sorry if I miss some rules. 3 Questions I was reading the documentation cause of a life bug This is
Job.kt
Copy code
* A job can have a _parent_ job. A job with a parent is cancelled when its parent is cancelled.
 * Parent job waits in _completing_ or _cancelling_ state for all its children to complete before finishing.
 * Note that _completing_ state is purely internal to the job. For an outside observer a _completing_ job is still
 * active, while internally it is waiting for its children.
 *
 * Normal cancellation of a job is distinguished from its failure by the type of its cancellation exception cause.
 * If the cause of cancellation is [CancellationException], then the job is considered to be _cancelled normally_.
 * This usually happens when [cancel] is invoked without additional parameters. If the cause of cancellation is
 * a different exception, then the job is considered to have _failed_. This usually happens when the code of the job
 * encounters some problem and throws an exception.
And this make me wonder, when I cancel the parent job
job.cancel()
and I have Channel using a children job: 1. What is already on execution will keep running until it ends? (that what I got from the docs) 2. What happen with the events in the Cue, will be discarded or will run until completion too? If 1 is true, I have a situation where channel-A call offer an event to channel-B, both in children jobs. When I close the parent job, with something running in Channel-A I got a
ClosedSendChannelException
(what is expected) I’m wondering what is the safest/better way to call the second channel? Should I
if(!eventChannel.isClosedForReceive)
or do we have a better way? Thanks!