aarc
Quickstart
Arc: a replacement for the standard library'sArc, but implemented with deferred reclamation semantics.AtomicArc: anArcwith an atomically updatable pointer. Supports standard atomic operations likecompare_exchange.Guard: A special smart pointer that is loaded fromAtomicArc. It is similar toArcin that it prevents deallocation, but it does not contribute to reference counts. This reduces contention when multiple threads operate on the same variable.
Motivation
Data structures built with Arc typically require locks for synchronization, as only
the reference counts may be atomically updated, not the pointer nor the contained data. While locks
are often the right approach, lock-free data structures can have better theoretical and practical
performance guarantees in highly-contended and/or read-heavy settings.
Instead of protecting in-place updates with locks, an alternative approach is to perform copy-on-write updates by
atomically installing pointers. To avoid use-afer-free, mechanisms for safe memory reclamation (SMR) are typically
utilized (i.e. hazard pointers, epoch-based reclamation). aarc uses the wait-free and robust algorithm provided by
the fast-smr crate and builds on top of it, hiding unsafety and providing
convenient RAII semantics through reference-counted pointers.
Examples
Example 1: Treiber Stack
use null;
use ;