Fantom

 

const final class

concurrent::AtomicInt

sys::Obj
  concurrent::AtomicInt

AtomicInt is used to manage an integer variable shared between actor/threads with atomic updates.

Slots

addAndGetSource

native Int addAndGet(Int delta)

Atomically add the given value to the current value and return the updated value.

compareAndSetSource

native Bool compareAndSet(Int expect, Int update)

Atomically set the value to update if current value is equivalent to the expect value. Return true if updated, or false if current value was not equal to the expected value.

decrementAndGetSource

native Int decrementAndGet()

Atomically increment the current value by one and return the updated value.

getAndAddSource

native Int getAndAdd(Int delta)

Atomically add the given value to the current value and return the previous value.

getAndDecrementSource

native Int getAndDecrement()

Atomically decrement the current value by one and return the previous value.

getAndIncrementSource

native Int getAndIncrement()

Atomically increment the current value by one and return the previous value.

getAndSetSource

native Int getAndSet(Int val)

Atomically set the value and return the previous value.

incrementAndGetSource

native Int incrementAndGet()

Atomically increment the current value by one and return the updated value.

makeSource

new make(Int val := 0)

Construct with initial value

toStrSource

override Str toStr()

Overrides sys::Obj.toStr

Return val.toStr

valSource

native Int val

The current integer value