arrow-fx / arrow.fx / IO / fork
fun fork(ctx:
CoroutineContext
):
IO
<
Fiber
<
ForIO
, A>>
Create a new IO that upon execution starts the receiver IO within a Fiber on ctx.
import arrow.fx.*
import arrow.fx.extensions.fx
import kotlinx.coroutines.Dispatchers
fun main(args: Array<String>) {
//sampleStart
val result = IO.fx {
val (join, cancel) = !IO.effect {
println("Hello from a fiber on ${Thread.currentThread().name}")
}.fork(Dispatchers.Default)
}
//sampleEnd
result.unsafeRunSync()
}
ctx
- CoroutineContext to execute the source IO on.
Receiver IO to execute on ctx within a new suspended IO.
Return IO with suspended execution of source IO on context ctx.
Do you like Arrow?
✖