Function crossbeam_utils::atomic::atomic_cell::lock

source ·
fn lock(addr: usize) -> &'static SeqLock
Expand description

Returns a reference to the global lock associated with the AtomicCell at address addr.

This function is used to protect atomic data which doesn’t fit into any of the primitive atomic types in std::sync::atomic. Operations on such atomics must therefore use a global lock.

However, there is not only one global lock but an array of many locks, and one of them is picked based on the given address. Having many locks reduces contention and improves scalability.