Module lrs::atomic

Atomic integers

Types

KindNameDescription
Typedef AtomicCInt
Struct AtomicI16

An atomic integer wrapper.

Struct AtomicI32

An atomic integer wrapper.

Struct AtomicI64

An atomic integer wrapper.

Struct AtomicI8

An atomic integer wrapper.

Struct AtomicIsize

An atomic integer wrapper.

Struct AtomicU16

An atomic integer wrapper.

Struct AtomicU32

An atomic integer wrapper.

Struct AtomicU64

An atomic integer wrapper.

Struct AtomicU8

An atomic integer wrapper.

Struct AtomicUsize

An atomic integer wrapper.

Functions

NameDescription
fence

Creates a sequentially consistent fence.

fence_acquire

Creates an acquire fence.

fence_acquire_release

Creates an acquire-release fence.

fence_release

Creates a release fence.

Constants

NameDescription
ATOMIC_CINT_INIT
ATOMIC_I16_INIT

A zero initializer for static variables.

ATOMIC_I32_INIT

A zero initializer for static variables.

ATOMIC_I64_INIT

A zero initializer for static variables.

ATOMIC_I8_INIT

A zero initializer for static variables.

ATOMIC_ISIZE_INIT

A zero initializer for static variables.

ATOMIC_U16_INIT

A zero initializer for static variables.

ATOMIC_U32_INIT

A zero initializer for static variables.

ATOMIC_U64_INIT

A zero initializer for static variables.

ATOMIC_U8_INIT

A zero initializer for static variables.

ATOMIC_USIZE_INIT

A zero initializer for static variables.

Remarks

This module contains integer wrappers with atomic operations. All types support the same operations:

new Creates a new object with the specified value.
wrap Wraps the integer as an atomic integer. The integer must be aligned and must not be accessed non-atomically concurrently or the behavior is undefined.
unwrap Returns a mutable pointer to the integer.
load Loads the value.
store Stores a new value.
exchange Stores a new value and returns the old one.
compare_exchange Compares the current value to a given one and if they match replaces the value by by a new one. Returns the old value.
add Adds a value to the current value and returns the old value.
sub, and, or, nand, xor Like add.
min Stores the minimum of the current value and a new value. Returns the old value.
max Like min.

The default ordering is sequentially consistent. The other available orderings are

See the C++11 standard for a concise description of these orderings.