brett.wooldridge06/11/2019, 6:16 AM
louiscad06/11/2019, 6:18 AM
like with any single execution cancellable/unregisterable callback.
brett.wooldridge06/11/2019, 6:20 AM
and the ability to suspend for nanoseconds (or microseconds) is not clear to me.
louiscad06/11/2019, 6:21 AM
function with it and an API from the platform that allows delaying with nanoseconds parameter.
brett.wooldridge06/11/2019, 6:24 AM
is a blocking call, but
is a suspending call, so how is the delay itself achieved without invoking an underlying blocking platform call?
octylFractal06/11/2019, 6:33 AM
brett.wooldridge06/11/2019, 6:36 AM
may not actually resume until tens, hundreds, or even thousands of milliseconds later)
elizarov06/11/2019, 6:52 AM
octylFractal06/11/2019, 7:02 AM
is a suspending call", it depends on the underlying implementation, but typically, the thread pool will do the blocking. the difference being, the thread pool can do other work that is ready while waiting for your task to finish delaying, since it knows of all the tasks it needs to be executing. essentially, when you call
, Kotlin schedules a task after the delay that calls back into your method to continue execution. see the generated bytecode, it basically is a switch statement to which part of the method it should be executing, and suspending will just tell it to call the next part.
brett.wooldridge06/11/2019, 7:11 AM
and does all internal math based on nanoseconds…would be nice to have it exposed. When is
expected to be added to stdlib? 1.4?