getAndSet

suspend fun <A> TVar<A>.getAndSet(value: A): A(source)

Atomically reads the current value and replaces it with value.

Example:

val tvar = TVar.new("old")
val previous = tvar.getAndSet("new") // "old"

Return

the old value before the swap

Parameters

value

the new value to set