logos.lang.atomic
Module lang · package logos-lang
Types
structAtomicBool
struct AtomicBool
Wraps a bool for lock-free atomic access; backed by an i32 (0 = false, 1 = true).
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicBool, expected: bool, desired: bool) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicBool, expected: bool, desired: bool, _success: Ordering, _failure: Ordering) -> bool
Performs compare_exchange; the ordering arguments are currently ignored (seq-cst).
fn load(self: &AtomicBool) -> bool
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicBool, _ord: Ordering) -> bool
Loads the current value; the ordering argument is currently ignored (seq-cst).
fn store(self: *mut AtomicBool, v: bool) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicBool, v: bool, _ord: Ordering) -> void
Stores v; the ordering argument is currently ignored (seq-cst).
fn swap_true(self: *mut AtomicBool) -> bool
Stores true and returns the previous value.
structAtomicI16
struct AtomicI16
Wraps an i16 for lock-free atomic access; storage widened to 32 bits (4-byte footprint).
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicI16, expected: i16, desired: i16) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicI16, expected: i16, desired: i16, _success: Ordering, _failure: Ordering) -> bool
Performs compare_exchange; the ordering arguments are currently ignored (seq-cst).
fn fetch_add(self: *mut AtomicI16, delta: i16) -> i16
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicI16, delta: i16, _ord: Ordering) -> i16
Atomically adds delta, returning the previous value; ordering currently ignored (seq-cst).
fn fetch_sub(self: *mut AtomicI16, delta: i16) -> i16
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn load(self: &AtomicI16) -> i16
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicI16, _ord: Ordering) -> i16
Loads the current value; the ordering argument is currently ignored (seq-cst).
fn store(self: *mut AtomicI16, v: i16) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicI16, v: i16, _ord: Ordering) -> void
Stores v; the ordering argument is currently ignored (seq-cst).
structAtomicI32
struct AtomicI32
Wraps an i32 for lock-free atomic access shared across threads and fibers.
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicI32, expected: i32, desired: i32) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicI32, expected: i32, desired: i32, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn compare_exchange_weak(self: *mut AtomicI32, expected: i32, desired: i32) -> bool
Performs a weak compare_exchange that may fail spuriously; intended for retry loops.
fn compare_exchange_weak_ordered(self: *mut AtomicI32, expected: i32, desired: i32, success: Ordering, failure: Ordering) -> bool
Performs a weak compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicI32, delta: i32) -> i32
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicI32, delta: i32, ord: Ordering) -> i32
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_and(self: *mut AtomicI32, v: i32) -> i32
Atomically ANDs v into the value, returning the previous value.
fn fetch_and_ordered(self: *mut AtomicI32, v: i32, ord: Ordering) -> i32
Atomically ANDs v into the value using ordering ord, returning the previous value.
fn fetch_or(self: *mut AtomicI32, v: i32) -> i32
Atomically ORs v into the value, returning the previous value.
fn fetch_or_ordered(self: *mut AtomicI32, v: i32, ord: Ordering) -> i32
Atomically ORs v into the value using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicI32, delta: i32) -> i32
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicI32, delta: i32, ord: Ordering) -> i32
Atomically subtracts delta using ordering ord, returning the previous value.
fn fetch_xor(self: *mut AtomicI32, v: i32) -> i32
Atomically XORs v into the value, returning the previous value.
fn fetch_xor_ordered(self: *mut AtomicI32, v: i32, ord: Ordering) -> i32
Atomically XORs v into the value using ordering ord, returning the previous value.
fn load(self: &AtomicI32) -> i32
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicI32, ord: Ordering) -> i32
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicI32, v: i32) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicI32, v: i32, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
fn swap(self: *mut AtomicI32, v: i32) -> i32
Atomically replaces the value with v, returning the previous value.
fn swap_ordered(self: *mut AtomicI32, v: i32, ord: Ordering) -> i32
Atomically replaces the value with v using ordering ord, returning the previous value.
structAtomicI64
struct AtomicI64
Wraps an i64 for lock-free atomic access shared across threads and fibers.
Fields
val: i64
Methods
fn compare_exchange(self: *mut AtomicI64, expected: i64, desired: i64) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicI64, expected: i64, desired: i64, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicI64, delta: i64) -> i64
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicI64, delta: i64, ord: Ordering) -> i64
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicI64, delta: i64) -> i64
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicI64, delta: i64, ord: Ordering) -> i64
Atomically subtracts delta using ordering ord, returning the previous value.
fn load(self: &AtomicI64) -> i64
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicI64, ord: Ordering) -> i64
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicI64, v: i64) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicI64, v: i64, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
structAtomicI8
struct AtomicI8
Wraps an i8 for lock-free atomic access; storage widened to 32 bits (4-byte footprint).
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicI8, expected: i8, desired: i8) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicI8, expected: i8, desired: i8, _success: Ordering, _failure: Ordering) -> bool
Performs compare_exchange; the ordering arguments are currently ignored (seq-cst).
fn fetch_add(self: *mut AtomicI8, delta: i8) -> i8
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicI8, delta: i8, _ord: Ordering) -> i8
Atomically adds delta, returning the previous value; ordering currently ignored (seq-cst).
fn fetch_sub(self: *mut AtomicI8, delta: i8) -> i8
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn load(self: &AtomicI8) -> i8
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicI8, _ord: Ordering) -> i8
Loads the current value; the ordering argument is currently ignored (seq-cst).
fn store(self: *mut AtomicI8, v: i8) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicI8, v: i8, _ord: Ordering) -> void
Stores v; the ordering argument is currently ignored (seq-cst).
structAtomicIsize
struct AtomicIsize
Wraps an isize (64-bit on this target) for lock-free atomic access; i64-backed.
Fields
val: i64
Methods
fn compare_exchange(self: *mut AtomicIsize, expected: isize, desired: isize) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicIsize, expected: isize, desired: isize, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicIsize, delta: isize) -> isize
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicIsize, delta: isize, ord: Ordering) -> isize
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicIsize, delta: isize) -> isize
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicIsize, delta: isize, ord: Ordering) -> isize
Atomically subtracts delta using ordering ord, returning the previous value.
fn load(self: &AtomicIsize) -> isize
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicIsize, ord: Ordering) -> isize
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicIsize, v: isize) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicIsize, v: isize, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
structAtomicPtr
struct AtomicPtr
Wraps a raw *mut T pointer for lock-free atomic access; stored as i64 bits.
Fields
val: i64
structAtomicU16
struct AtomicU16
Wraps a u16 for lock-free atomic access; storage widened to 32 bits (4-byte footprint).
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicU16, expected: u16, desired: u16) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicU16, expected: u16, desired: u16, _success: Ordering, _failure: Ordering) -> bool
Performs compare_exchange; the ordering arguments are currently ignored (seq-cst).
fn fetch_add(self: *mut AtomicU16, delta: u16) -> u16
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicU16, delta: u16, _ord: Ordering) -> u16
Atomically adds delta, returning the previous value; ordering currently ignored (seq-cst).
fn fetch_sub(self: *mut AtomicU16, delta: u16) -> u16
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn load(self: &AtomicU16) -> u16
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicU16, _ord: Ordering) -> u16
Loads the current value; the ordering argument is currently ignored (seq-cst).
fn store(self: *mut AtomicU16, v: u16) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicU16, v: u16, _ord: Ordering) -> void
Stores v; the ordering argument is currently ignored (seq-cst).
structAtomicU32
struct AtomicU32
Wraps a u32 for lock-free atomic access; stored internally as i32 bits.
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicU32, expected: u32, desired: u32) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicU32, expected: u32, desired: u32, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicU32, delta: u32) -> u32
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicU32, delta: u32, ord: Ordering) -> u32
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicU32, delta: u32) -> u32
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicU32, delta: u32, ord: Ordering) -> u32
Atomically subtracts delta using ordering ord, returning the previous value.
fn load(self: &AtomicU32) -> u32
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicU32, ord: Ordering) -> u32
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicU32, v: u32) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicU32, v: u32, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
structAtomicU64
struct AtomicU64
Wraps a u64 for lock-free atomic access; stored internally as i64 bits.
Fields
val: i64
Methods
fn compare_exchange(self: *mut AtomicU64, expected: u64, desired: u64) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicU64, expected: u64, desired: u64, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicU64, delta: u64) -> u64
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicU64, delta: u64, ord: Ordering) -> u64
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicU64, delta: u64) -> u64
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicU64, delta: u64, ord: Ordering) -> u64
Atomically subtracts delta using ordering ord, returning the previous value.
fn load(self: &AtomicU64) -> u64
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicU64, ord: Ordering) -> u64
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicU64, v: u64) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicU64, v: u64, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
structAtomicU8
struct AtomicU8
Wraps a u8 for lock-free atomic access; storage widened to 32 bits (4-byte footprint).
Fields
val: i32
Methods
fn compare_exchange(self: *mut AtomicU8, expected: u8, desired: u8) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicU8, expected: u8, desired: u8, _success: Ordering, _failure: Ordering) -> bool
Performs compare_exchange; the ordering arguments are currently ignored (seq-cst).
fn fetch_add(self: *mut AtomicU8, delta: u8) -> u8
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicU8, delta: u8, _ord: Ordering) -> u8
Atomically adds delta, returning the previous value; ordering currently ignored (seq-cst).
fn fetch_sub(self: *mut AtomicU8, delta: u8) -> u8
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn load(self: &AtomicU8) -> u8
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicU8, _ord: Ordering) -> u8
Loads the current value; the ordering argument is currently ignored (seq-cst).
fn store(self: *mut AtomicU8, v: u8) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicU8, v: u8, _ord: Ordering) -> void
Stores v; the ordering argument is currently ignored (seq-cst).
structAtomicUsize
struct AtomicUsize
Wraps a usize (64-bit on this target) for lock-free atomic access; i64-backed.
Fields
val: i64
Methods
fn compare_exchange(self: *mut AtomicUsize, expected: usize, desired: usize) -> bool
Atomically replaces the value with desired if it equals expected; returns true on success.
fn compare_exchange_ordered(self: *mut AtomicUsize, expected: usize, desired: usize, success: Ordering, failure: Ordering) -> bool
Performs compare_exchange with explicit success/failure orderings.
fn fetch_add(self: *mut AtomicUsize, delta: usize) -> usize
Atomically adds delta, returning the previous value; wraps on overflow.
fn fetch_add_ordered(self: *mut AtomicUsize, delta: usize, ord: Ordering) -> usize
Atomically adds delta using ordering ord, returning the previous value.
fn fetch_sub(self: *mut AtomicUsize, delta: usize) -> usize
Atomically subtracts delta, returning the previous value; wraps on overflow.
fn fetch_sub_ordered(self: *mut AtomicUsize, delta: usize, ord: Ordering) -> usize
Atomically subtracts delta using ordering ord, returning the previous value.
fn load(self: &AtomicUsize) -> usize
Loads the current value (seq-cst).
fn load_ordered(self: &AtomicUsize, ord: Ordering) -> usize
Loads the value using ordering ord; a non-literal ord degrades to seq-cst.
fn store(self: *mut AtomicUsize, v: usize) -> void
Stores v atomically (seq-cst).
fn store_ordered(self: *mut AtomicUsize, v: usize, ord: Ordering) -> void
Stores v using ordering ord; a non-literal ord degrades to seq-cst.
enumOrdering
enum Ordering
Specifies memory ordering for atomic operations; mirrors core::sync::atomic::Ordering.
On the x86-64 backend every variant currently lowers to the same seq-cst primitive (see module header); the distinction matters on weaker targets.
Variants
AcqRel
Acquire
Relaxed
Release
SeqCst
Functions
fnatomic_bool_new
fn atomic_bool_new(v: bool) -> AtomicBool
Creates an AtomicBool initialized to v.
fnatomic_i16_new
fn atomic_i16_new(v: i16) -> AtomicI16
Creates an AtomicI16 initialized to v.
fnatomic_i32_new
fn atomic_i32_new(v: i32) -> AtomicI32
Creates an AtomicI32 initialized to v.
fnatomic_i64_new
fn atomic_i64_new(v: i64) -> AtomicI64
Creates an AtomicI64 initialized to v.
fnatomic_i8_new
fn atomic_i8_new(v: i8) -> AtomicI8
Creates an AtomicI8 initialized to v.
fnatomic_isize_new
fn atomic_isize_new(v: isize) -> AtomicIsize
Creates an AtomicIsize initialized to v.
fnatomic_ptr_new
fn atomic_ptr_new(p: *mut T) -> AtomicPtr<T>
Creates an AtomicPtr<T> initialized to p.
fnatomic_ptr_null
fn atomic_ptr_null() -> AtomicPtr<T>
Creates an AtomicPtr<T> initialized to the null pointer.
fnatomic_u16_new
fn atomic_u16_new(v: u16) -> AtomicU16
Creates an AtomicU16 initialized to v.
fnatomic_u32_new
fn atomic_u32_new(v: u32) -> AtomicU32
Creates an AtomicU32 initialized to v.
fnatomic_u64_new
fn atomic_u64_new(v: u64) -> AtomicU64
Creates an AtomicU64 initialized to v.
fnatomic_u8_new
fn atomic_u8_new(v: u8) -> AtomicU8
Creates an AtomicU8 initialized to v.
fnatomic_usize_new
fn atomic_usize_new(v: usize) -> AtomicUsize
Creates an AtomicUsize initialized to v.