<@U0BLPSJAK> The prototype code for cancellable co...
# coroutines
e
@Deactivated User The prototype code for cancellable coroutines is here: https://github.com/elizarov/CancellableCoroutinesPlayground/tree/master/src In this codebase you can do stuff like this inside your coroutines:
Copy code
withTimeout(1000L) { … do some suspending stuff here … }
and it’ll throw
CancellationException
if that stuff takes longer than timeout. It nests to any depth. There is a version of
await()
that supports cancellation. There is also a
suspendCancellableCoroutine
utility function (that returns you a
CancellableContinuation
) that lets you easily write your own cancellable suspending functions.
👍 2