arrow-fx-stm / arrow.fx.stm / STM / write
abstract fun <A>
TVar
<A>.write(a: A):
Unit
Set the value of a TVar.
import arrow.fx.stm.TVar
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tvar = TVar.new(10)
val result = atomically {
tvar.write(20)
}
//sampleEnd
println(result)
}
Similarly to read this comes with a few guarantees:
open fun <A>
TQueue
<A>.write(a: A):
Unit
Append an element to the TQueue.
import arrow.fx.stm.TQueue
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tq = TQueue.new<Int>()
atomically {
tq.write(2)
}
//sampleEnd
println("Items in queue ${atomically { tq.flush() }}")
}
This function never retries.
Do you like Arrow?
✖