updateAndGet

inline fun AtomicLong.updateAndGet(block: (Long) -> Long): Long(source)

Update value by AtomicLong.compareAndSet and then return the new value.

while (true) {
val current = value
val new = block(current)
if (compareAndSet(current, new)) {
return new
}
}

Return

The new value that been exchanged.


inline fun AtomicInt.updateAndGet(block: (Int) -> Int): Int(source)

Update value by AtomicInt.compareAndSet and then return the new value.

while (true) {
val current = value
val new = block(current)
if (compareAndSet(current, new)) {
return new
}
}

Return

The new value that been exchanged.


inline fun AtomicULong.updateAndGet(block: (ULong) -> ULong): ULong(source)

Update value by AtomicULong.compareAndSet and then return the new value.

while (true) {
val current = value
val new = block(current)
if (compareAndSet(current, new)) {
return new
}
}

Return

The new value that been exchanged.


inline fun AtomicUInt.updateAndGet(block: (UInt) -> UInt): UInt(source)

Update value by AtomicUInt.compareAndSet and then return the new value.

while (true) {
val current = value
val new = block(current)
if (compareAndSet(current, new)) {
return new
}
}

Return

The new value that been exchanged.


inline fun <T> AtomicRef<T>.updateAndGet(block: (T) -> T): T(source)

Update value by AtomicRef.compareAndSet and then return the new value.

while (true) {
val current = value
val new = block(current)
if (compareAndSet(current, new)) {
return new
}
}

Return

The new value that been exchanged.