put
Put a value into an empty TMVar.
import arrow.fx.stm.TMVar
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tmvar = TMVar.empty<Int>()
atomically {
tmvar.put(20)
}
//sampleEnd
println("New value ${atomically { tmvar.tryTake() } }")
}
Content copied to clipboard
This retries if the TMVar is not empty.
For a version of TMVar.put that does not retry see TMVar.tryPut