getAndUpdate

inline fun <V> Atomic<V>.getAndUpdate(function: (V) -> V): V
inline fun AtomicBoolean.getAndUpdate(function: (Boolean) -> Boolean): Boolean
inline fun AtomicInt.getAndUpdate(function: (Int) -> Int): Int
inline fun AtomicLong.getAndUpdate(function: (Long) -> Long): Long

Updates variable atomically using the specified function of its value and returns its old value.