Skip to main content

Crate kovan

Crate kovan 

Source
Expand description

Kovan: High-performance wait-free memory reclamation for lock-free data structures. Bounded memory usage, predictable latency.

Kovan implements a wait-free safe memory reclamation (SMR) algorithm based on the Crystalline / ASMR design. Unlike epoch-based reclamation (EBR) or hazard pointers, kovan guarantees bounded worst-case latency for every operation — no thread can be starved, even under contention.

§Key Properties

  • Wait-Free Progress: Every operation completes in a bounded number of steps, regardless of what other threads are doing. Stalled threads are helped to completion by concurrent threads.
  • Zero Read Overhead: Object loads require only a single atomic read — the same cost as a raw AtomicPtr::load.
  • Bounded Memory: Retired nodes are reclaimed in bounded batches. The reclamation system cannot accumulate unbounded garbage, even with stalled threads.
  • no_std Compatible: Uses only alloc. No standard library required.

§Architecture

  • Per-thread epoch slots: Each thread maintains a slot recording its current epoch. Slots are protected by 128-bit DCAS (double compare-and-swap).
  • Batch retirement: Retired nodes are accumulated in thread-local batches of 64 and distributed across active slots via try_retire.
  • Wait-free helping: Threads in the slow path publish their state so other threads can help them complete, ensuring system-wide progress.

§Example

use kovan::Atom;

// High-level API: safe, zero-overhead reads
let config = Atom::new(vec![1, 2, 3]);
let guard = config.load();
assert_eq!(guard.len(), 3);

Structs§

Atom
A lock-free single-value container with safe memory reclamation.
AtomGuard
RAII guard returned by Atom::load().
AtomMap
A projected view into an Atom<T>, created by Atom::map().
AtomMapGuard
Guard for a mapped/projected load.
AtomOption
Like Atom<T> but allows a null/empty state.
Atomic
A pointer to a heap-allocated value with atomic operations.
BirthEra
Birth era for a node
Guard
RAII guard representing an active critical section.
Removed
A value removed from an Atom or AtomOption.
RetiredNode
Node structure embedded in user’s data structure.
Shared
A pointer to a heap-allocated value protected by a guard.

Enums§

Ordering
Atomic memory orderings

Traits§

Reclaimable
Trait for types that can be reclaimed by the wait-free memory reclamation system.

Functions§

current_era
Get current global era
flush
Flush all retired nodes on the calling thread.
pin
Enter a critical section.
retire
Retire a node for later reclamation.