elizarov
08/09/2017, 5:11 PMJob
is perfect match for your lifecycle-management interface (its original pre-release name was Lifecycle
, btw), but you have to be careful about what guarantees you get when you cancel a set of running coroutines. The guarantee that Job.cancel()
gives you is that all coroutines will get immediately and synchronously notified on cancellation, but when they actually stop working is a whole different story (it is cooperative, they have to cooperate to make sure it happens in a timely manner).