Expand description
Primitives that make it easy to implement correct lock-free algorithms
atomic_try_update
is the main entry-point to this library, but (with
the exception of NonceStack
) the included example code is also designed
to be used in production. Each module implements a different family of
example algorithms. If you simply want to use general-purpose algorithms
without modification, start with the public APIs of the data structures
in those modules.
If you want to start implementing your own specialized lock-free logic, start with this page, then read the top-level descriptions of each of the modules this crate exports.
Modules§
- barrier
- User-friendly barriers that use
atomic_try_update
to handle startup and teardown race conditions. - bits
- Bit packing and pointer alignment utilities that make it easier to fit
additional state into an
Atom<T>
- claim
- Examples of the claim mutual exclusion pattern, including an example of the claim_queue, which allows multiple workers to enqueue work and ensures that exactly one worker running if there is work to be done.
- once
- A wait-free alternative to
std::sync::OnceLock
, with helper methods that make it easier to correctly register state at startup. - stack
- Lightweight lock-free stack implementations
Structs§
- Atom
- A wrapper that allows an instance of type T to be treated as though it is
an atomic integer type (in the style of a C/C++ union). Use
atomic_try_update
to access the data of typeT
stored in anAtom<T>
. - Node
- A linked list node that contains an instance of type T and a raw pointer
to the next entry in the node. Since
atomic_try_update
speculatively executes code, it can not handle values ofBox<T>
soundly. Therefore, this is the idiomatic way to store linked lists and stacks withatomic_try_update
. - Node
Iterator - A consuming iterator over a value of type Node.
Functions§
- atomic_
try_ ⚠update - This function is used to implement lock free synchronization primitives.