Get the current value as an Option
Atomically get the current value and set to null
Update from the old to a new value and return the newly computed value.
Update from the old to a new value and return the newly computed value.
Note that the passed function must be pure as it may be re-computed if there is contention when setting the updated value.
Update from the old to a new value and return a companion value computed at the same time.
Alias for get
Update method that allows the form:
Update method that allows the form:
value = updateFunction(_)
Extension to
AtomicReference
that allows more idiomatic usage.It adds a value that can be set with an update function:
value = (a: A) => calculate(a) value = calculate(_)