TwoClocks
07/16/2020, 7:53 PMoctylFractal
07/16/2020, 7:54 PMTwoClocks
07/16/2020, 7:55 PMTwoClocks
07/16/2020, 7:56 PMTwoClocks
07/16/2020, 7:56 PMoctylFractal
07/16/2020, 7:56 PMExecutor.asDispatcher()
, your executor is the queueTwoClocks
07/16/2020, 7:56 PMoctylFractal
07/16/2020, 7:58 PMoctylFractal
07/16/2020, 8:01 PMoctylFractal
07/16/2020, 8:01 PMTwoClocks
07/16/2020, 8:01 PMTwoClocks
07/16/2020, 8:02 PMTwoClocks
07/16/2020, 8:02 PMoctylFractal
07/16/2020, 8:04 PMDelay
on your dispatcher if you would like to intercept thatoctylFractal
07/16/2020, 8:04 PMoctylFractal
07/16/2020, 8:04 PMTwoClocks
07/16/2020, 8:07 PMTwoClocks
07/16/2020, 8:07 PMTwoClocks
07/16/2020, 8:08 PMoctylFractal
07/16/2020, 8:09 PMoctylFractal
07/16/2020, 8:09 PMTwoClocks
07/16/2020, 8:10 PMoctylFractal
07/16/2020, 8:10 PMTwoClocks
07/16/2020, 8:12 PMTwoClocks
07/16/2020, 8:12 PMoctylFractal
07/16/2020, 8:14 PMsuspend
a blocking operationTwoClocks
07/16/2020, 8:14 PMTwoClocks
07/16/2020, 8:15 PMTwoClocks
07/16/2020, 8:16 PMTwoClocks
07/16/2020, 8:16 PMoctylFractal
07/16/2020, 8:16 PMsuspendCoroutine { ... }
block that hands the continuation over to a thread running select()
TwoClocks
07/16/2020, 8:18 PMoctylFractal
07/16/2020, 8:18 PMoctylFractal
07/16/2020, 8:18 PMdelay
calls, they're handled by the actual dispatcher, whatever it isTwoClocks
07/16/2020, 8:19 PMoctylFractal
07/16/2020, 8:20 PMsuspendCoroutine { ... }
will not be calling select, it is a hand-off to the single thread running selectoctylFractal
07/16/2020, 8:21 PMcont.resume
in the select-thread, it goes back to the original dispatcher and starts executing thereTwoClocks
07/16/2020, 8:21 PMTwoClocks
07/16/2020, 8:22 PMTwoClocks
07/16/2020, 8:23 PMoctylFractal
07/16/2020, 8:24 PMoctylFractal
07/16/2020, 8:25 PMoctylFractal
07/16/2020, 8:25 PMTwoClocks
07/16/2020, 8:25 PMoctylFractal
07/16/2020, 8:26 PMsuspend fun callIO() { suspendCoroutine { passToSelect() } }
octylFractal
07/16/2020, 8:26 PMdelay
, that never touches this codeTwoClocks
07/16/2020, 8:29 PMTwoClocks
07/16/2020, 8:30 PMTwoClocks
07/16/2020, 8:31 PMoctylFractal
07/16/2020, 8:31 PMTwoClocks
07/16/2020, 8:31 PMoctylFractal
07/16/2020, 8:31 PMTwoClocks
07/16/2020, 8:33 PMTwoClocks
07/16/2020, 8:34 PMTwoClocks
07/16/2020, 8:34 PMoctylFractal
07/16/2020, 8:36 PMTwoClocks
07/16/2020, 8:36 PMTwoClocks
07/16/2020, 8:36 PMoctylFractal
07/16/2020, 8:37 PMTwoClocks
07/16/2020, 8:37 PMoctylFractal
07/16/2020, 8:37 PMoctylFractal
07/16/2020, 8:37 PMDispatchers.Default
, <http://Dispatchers.IO|Dispatchers.IO>
TwoClocks
07/16/2020, 8:38 PMoctylFractal
07/16/2020, 8:39 PMTwoClocks
07/16/2020, 8:39 PMoctylFractal
07/16/2020, 8:40 PMoctylFractal
07/16/2020, 8:40 PMTwoClocks
07/16/2020, 8:40 PMoctylFractal
07/16/2020, 8:40 PMoctylFractal
07/16/2020, 8:41 PMselect()
octylFractal
07/16/2020, 8:41 PMContinuation
from suspendCancellableCoroutine
and the relevant info for select()
octylFractal
07/16/2020, 8:41 PMContinuation.resume
TwoClocks
07/16/2020, 8:41 PMoctylFractal
07/16/2020, 8:41 PMoctylFractal
07/16/2020, 8:41 PMTwoClocks
07/16/2020, 8:42 PMoctylFractal
07/16/2020, 8:42 PMTwoClocks
07/16/2020, 8:42 PMoctylFractal
07/16/2020, 8:43 PMTwoClocks
07/16/2020, 8:43 PMoctylFractal
07/16/2020, 8:43 PMTwoClocks
07/16/2020, 8:44 PMTwoClocks
07/16/2020, 8:45 PMoctylFractal
07/16/2020, 8:45 PMTwoClocks
07/16/2020, 8:46 PMoctylFractal
07/16/2020, 8:46 PMoctylFractal
07/16/2020, 8:46 PMsuspend
octylFractal
07/16/2020, 8:46 PMTwoClocks
07/16/2020, 8:47 PMTwoClocks
07/16/2020, 8:47 PMoctylFractal
07/16/2020, 8:48 PMcoroutines
library from your classpathoctylFractal
07/16/2020, 8:48 PMsuspend
is a kotlin compiler feature, you don't need the library to use it, see e.g. Sequence
which is suspend
-based, but not from the coroutine libTwoClocks
07/16/2020, 8:48 PMTwoClocks
07/16/2020, 8:49 PMoctylFractal
07/16/2020, 8:49 PMlaunch {}
is part of that libraryoctylFractal
07/16/2020, 8:50 PMsuspendCoroutine
is not part of that library, it's part of the stdlibTwoClocks
07/16/2020, 8:50 PMTwoClocks
07/16/2020, 8:50 PMoctylFractal
07/16/2020, 8:54 PMoctylFractal
07/16/2020, 8:54 PMiterator()
octylFractal
07/16/2020, 8:56 PMblock.createCoroutineUnintercepted
, and then resume
it wherever you want it to startTwoClocks
07/16/2020, 8:56 PMoctylFractal
07/16/2020, 8:56 PMhasNext
TwoClocks
07/16/2020, 8:58 PMoctylFractal
07/16/2020, 8:58 PMTwoClocks
07/16/2020, 8:59 PMTwoClocks
07/16/2020, 8:59 PMTwoClocks
07/16/2020, 8:59 PM