arrow-fx-coroutines / arrow.fx.coroutines / ConcurrentVar / put
abstract suspend fun put(a: A):
Unit
Puts A in the ConcurrentVar if it is empty, or suspends if full until the given value is next in line to be consumed by take.
import arrow.fx.coroutines.*
suspend fun main(): Unit {
//sampleStart
val mvar = ConcurrentVar.empty<Int>()
mvar.put(5)
val none = timeOutOrNull(1.seconds) {
mvar.put(10)
}
val res = mvar.take()
//sampleEnd
println("none: $none, res: $res")
}
See Also
Do you like Arrow?
✖