elizarov
12/27/2016, 5:59 PMwithTimeout(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.