par Sequence
Deprecated
Function is being renamed to parMap in 2.x.x
Replace with
import arrow.fx.coroutines.parMap
import kotlinx.coroutines.Dispatchers
parMap(Dispatchers.Default) { it() }Deprecated
Function is being renamed to parMap in 2.x.x
Replace with
import arrow.fx.coroutines.parMap
import kotlinx.coroutines.Dispatchers
parMap(Dispatchers.Default) { it() }Sequences all tasks in parallel on Dispatchers.Default and return the result
Cancelling this operation cancels all running tasks.
import arrow.fx.coroutines.*
typealias Task = suspend () -> Unit
suspend fun main(): Unit {
//sampleStart
fun getTask(id: Int): Task =
suspend { println("Working on task $id on ${Thread.currentThread().name}") }
val res = listOf(1, 2, 3)
.map(::getTask)
.parSequence()
//sampleEnd
println(res)
}Deprecated
Function is being renamed to parMap in 2.x.x
Replace with
import arrow.fx.coroutines.parMap
parMap(ctx) { it() }Deprecated
Function is being renamed to parMap in 2.x.x
Replace with
import arrow.fx.coroutines.parMap
parMap(ctx) { it() }Sequences all tasks in parallel and return the result
Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run in parallel.
Cancelling this operation cancels all running tasks.
import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers
typealias Task = suspend () -> Unit
suspend fun main(): Unit {
//sampleStart
fun getTask(id: Int): Task =
suspend { println("Working on task $id on ${Thread.currentThread().name}") }
val res = listOf(1, 2, 3)
.map(::getTask)
.parSequence(Dispatchers.IO)
//sampleEnd
println(res)
}