light-qsbr
A lightweight Quiescent-State-Based Reclamation (QSBR) library for Rust.
It provides a minimal, efficient mechanism for safe memory reclamation in concurrent and asynchronous runtimes, without the complexity of a garbage collector or hazard pointers.
โจ Features
- ๐ Extremely lightweight โ only the essential QSBR pieces.
- ๐งต Thread-local memory managers with a global epoch coordinator.
- ๐๏ธ Safe reclamation of memory scheduled by executors.
- ๐ ๏ธ Designed for async runtimes and lock-free data structures.
๐ Core Concepts
-
SharedManager
The global manager. Tracks the current epoch and number of executors. -
LocalManager
The thread-local manager. Each executor registers one and uses it to schedule memory for deallocation or dropping. -
Epochs
Executors periodically advance epochs. Memory is only freed once all executors have passed the epoch in which the memory was retired.
โก Quick Example
use ;
use OrengineInstant;
โ When to Use
-
Implementing lock-free collections that need safe reclamation.
-
Async runtimes that want QSBR without the overhead of hazard pointers.
-
Situations where you control the executor lifecycle and can enforce correct registration/deregistration.
๐ซ When Not to Use
-
If executors come and go frequently (executors are short-lived).
-
If you want fully automatic memory management (this is not a GC).