update

fun update(transform: (T) -> T)(source)

Atomically replaces the value with transform(current). transform may be re-invoked if another thread updates concurrently, so it must be side-effect free.

Parameters

transform

pure function from the current value to the new value.