Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/sync/atomic"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
error |
std/sync/error |
atomic.dodo |
mem |
core/mem |
atomic.dodo |
ptr |
core/ptr |
atomic.dodo |
Ordering
Enum · Source
Independent of every OS blocking adapter. The compiler emits LLVM atomics and rejects widths/targets without the documented native primitive support.
pub enum Ordering {
Relaxed, Acquire, Release, AcqRel, SeqCst
}
CompareExchange
Struct · Source
pub struct CompareExchange<T> {
pub previous: T
pub exchanged: bool
}
Atomic
Struct · Source
pub struct Atomic<T> {
// Private implementation fields omitted.
}
Atomic.new
Function · Source
pub fn new(value: T) -> Atomic<T>
Atomic.load
Function · Source
pub fn load(&self, order: Ordering) -> T!error.Error
Atomic.store
Function · Source
pub fn store(&self, value: T, order: Ordering) -> void!error.Error
Atomic.exchange
Function · Source
pub fn exchange(&self, value: T, order: Ordering) -> T!error.Error
Atomic.fetch_add
Function · Source
pub fn fetch_add(&self, value: T, order: Ordering) -> T!error.Error
Atomic.compare_exchange
Function · Source
pub fn compare_exchange(&self, expected: T, replacement: T, success: Ordering, failure: Ordering) -> CompareExchange<T>!error.Error