atom
atom provides atomic operations for integers, floats, and strings.
Functions
new_int(value=0) -> AtomicInt
create a new AtomicInt with an optional initial value
Parameters
name | type | description |
|---|---|---|
|
| initial value, defaults to 0 |
Examples
basic
create a new AtomicInt with default value
with value
create a new AtomicInt with a specific value
new_float(value=0.0) -> AtomicFloat
create a new AtomicFloat with an optional initial value
Parameters
name | type | description |
|---|---|---|
|
| initial value, defaults to 0.0 |
Examples
basic
create a new AtomicFloat with default value
with value
create a new AtomicFloat with a specific value
new_string(value="") -> AtomicString
create a new AtomicString with an optional initial value
Parameters
name | type | description |
|---|---|---|
|
| initial value, defaults to an empty string |
Examples
basic
create a new AtomicString with default value
with value
create a new AtomicString with a specific value
Types
AtomicInt
an atomic integer type with various atomic operations
Methods
get() -> int
returns the current value
set(value: int)
sets the value
cas(old: int, new: int) -> bool
compares and swaps the value if it matches old
add(delta: int) -> int
adds delta to the value and returns the new value
sub(delta: int) -> int
subtracts delta from the value and returns the new value
inc() -> int
increments the value by 1 and returns the new value
dec() -> int
decrements the value by 1 and returns the new value
AtomicFloat
an atomic float type with various atomic operations
Methods
get() -> float
returns the current value
set(value: float)
sets the value
cas(old: float, new: float) -> bool
compares and swaps the value if it matches old
add(delta: float) -> float
adds delta to the value and returns the new value
sub(delta: float) -> float
subtracts delta from the value and returns the new value
AtomicString
an atomic string type with various atomic operations
Methods
get() -> string
returns the current value
set(value: string)
sets the value
cas(old: string, new: string) -> bool
compares and swaps the value if it matches old