AtomicInt
An Int value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.
Constructors
<init>
An Int value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.
AtomicInt(value: Int)
Properties
value
var value: Int
Functions
addAndGet
Atomically adds the given value to the current value and returns the new value.
fun addAndGet(delta: Int): Int
compareAndExchange
Atomically sets the value to the given new value if the current value equals the expected value and returns the old value in any case.
fun compareAndExchange(expected: Int, newValue: Int): Int
compareAndSet
Atomically sets the value to the given new value if the current value equals the expected value, returns true if the operation was successful and false only if the current value was not equal to the expected value.
fun compareAndSet(expected: Int, newValue: Int): Boolean
decrementAndGet
Atomically decrements the current value by one and returns the new value.
fun decrementAndGet(): Int
getAndAdd
Atomically adds the given value to the current value and returns the old value.
fun getAndAdd(delta: Int): Int
getAndDecrement
Atomically decrements the current value by one and returns the old value.
fun getAndDecrement(): Int
getAndIncrement
Atomically increments the current value by one and returns the old value.
fun getAndIncrement(): Int
getAndSet
Atomically sets the value to the given new value and returns the old value.
fun getAndSet(newValue: Int): Int
incrementAndGet
Atomically increments the current value by one and returns the new value.
fun incrementAndGet(): Int