pakoito
12/16/2019, 2:24 PMpakoito
12/16/2019, 2:24 PMPPWasin
12/16/2019, 2:25 PMIt does not check cancellation when suspend functions are calling each other, although that feature will be added on a future release.
So, be mindful when using suspended() because cancellation won't propagate even when called from IO { } or effect { }.
Could you give me more details about it.pakoito
12/16/2019, 2:26 PMpakoito
12/16/2019, 2:26 PMsuspend fun bla() {
println("paco")
}
suspend fun ble() {
delay(300)
bla()
}
val first = IO { ble() }.flatMap { IO { println("peco") } }
IO.raceN(IO.dispatchers().default(), first, IO.just(Unit))
pakoito
12/16/2019, 2:28 PMpakoito
12/16/2019, 2:29 PMpakoito
12/16/2019, 2:30 PMble
, which delays 300ms. Meanwhile the second one completes immediately, triggering the cancellationpakoito
12/16/2019, 2:30 PM.flatMap
so ble
completes the delay and calls bla
pakoito
12/16/2019, 2:31 PMPPWasin
12/16/2019, 2:41 PMPPWasin
12/16/2019, 2:41 PMcancellation won't propagate
pakoito
12/16/2019, 2:42 PMble
calling bla
after the delaypakoito
12/16/2019, 2:43 PMpakoito
12/16/2019, 2:43 PMpakoito
12/16/2019, 2:43 PMfun suspend patatas() {
myIO.suspended()
}
pakoito
12/16/2019, 2:43 PMmyIO
will not be cancelled and will completePPWasin
12/16/2019, 2:44 PMPPWasin
12/16/2019, 2:45 PMPPWasin
12/16/2019, 2:47 PMPPWasin
12/16/2019, 2:47 PMpakoito
12/16/2019, 2:49 PMpakoito
12/16/2019, 2:49 PMsuspended
PPWasin
12/16/2019, 2:52 PMPPWasin
12/16/2019, 2:52 PMpakoito
12/16/2019, 2:54 PMPPWasin
12/16/2019, 2:55 PM