https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

08/09/2017, 5:20 PM
It is not hard to follow certain patterns to make sure your code is cancellable: * If you code is like “do something, delay, repeat”, the cancellability comes via
delay
* If your code is some CPU-heavy stuff, then you must rememeber to check
isActive
periodically * If your code is build with
generate
or
actor
builder, then you get cancellability “for free” by the virtue of the fact the coroutine’s lifecycle is integrated with lifecycle of the corresponding channel (but you still have to keep in mind CPU-consuming part if you have any of that)