How vorner/arc-swap works
ArcSwap is a Rust library providing atomic replacement and read access to reference-counted values, optimized for read-heavy workloads. The principal workflow is that application code loads a guarded value or stores a replacement; the selected strategy protects readers and safely reclaims replaced values. Supporting capabilities include alternative locking, weak-pointer swaps, projected and cached access, and Serde integration. The graph reflects documented behavior and relationships visible in the excerpts and SOURCE INDEX; unsampled implementation details are not assumed.
Main entry points: lib.rs ArcSwap API · strategy/mod.rs Strategy selection · hybrid.rs Hybrid protection · debt/mod.rs Debt management
Components 15
Public API
- ArcSwap API
src/lib.rs - Raw pointer adapters
src/as_raw.rs
Reader Protection
- Reference-count abstraction
src/ref_cnt.rs - Strategy selection
src/strategy/mod.rs - Hybrid protection
src/strategy/hybrid.rs - RwLock strategy
src/strategy/rw_lock.rs - Debt management
src/debt/mod.rs - Fast debt slots
src/debt/fast.rs - Helping slots
src/debt/helping.rs - Thread debt list
src/debt/list.rs
Access Extensions
- Projected access
src/access.rs - Cached access
src/cache.rs - Weak pointer API
src/weak.rs - Serde support
src/serde.rs
Other components
- Application code
Connections 22
- Application code → ArcSwap API: loads and stores
README.md - ArcSwap API → Strategy selection: uses
src/lib.rs - ArcSwap API → Projected access: exposes
src/lib.rs - ArcSwap API → Cached access: exposes
src/lib.rs - ArcSwap API → Weak pointer API: exposes
src/lib.rs - ArcSwap API → Serde support: integrates
src/lib.rs - Strategy selection → Hybrid protection: selects default
src/strategy/mod.rs - Strategy selection → RwLock strategy: supports alternative
src/strategy/mod.rs - Hybrid protection → Debt management: manages debts
src/strategy/hybrid.rs - Hybrid protection → Reference-count abstraction: protects values
src/strategy/hybrid.rs - Hybrid protection → Raw pointer adapters: uses pointers
src/strategy/hybrid.rs - RwLock strategy → Reference-count abstraction: adjusts counts
src/strategy/rw_lock.rs - RwLock strategy → Raw pointer adapters: adapts pointers
src/strategy/rw_lock.rs - Debt management → Thread debt list: uses nodes
src/debt/mod.rs - Debt management → Fast debt slots: uses slots
src/debt/mod.rs - Debt management → Helping slots: uses slots
src/debt/mod.rs - Thread debt list → Fast debt slots: allocates
src/debt/list.rs - Thread debt list → Helping slots: supports helping
src/debt/list.rs - Projected access → Strategy selection: uses guards
src/access.rs - Projected access → Reference-count abstraction: abstracts pointers
src/access.rs - Cached access → Reference-count abstraction: checks pointers
src/cache.rs - Cached access → Strategy selection: loads through
src/cache.rs