It is not hard to follow certain patterns to make ...
# coroutines
e
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)