Skip to main content

Crate concurrent_sharded_stack

Crate concurrent_sharded_stack 

Source
Expand description

A lock-free concurrent stack that shards a classic Treiber stack across multiple per-thread shards and reclaims memory with epoch-based GC.

See ConcurrentShardedStack for the main entry point. Compared to a single Treiber stack, sharding spreads CAS contention across independent cache-line-padded shards, at the cost of only providing LIFO ordering within a shard rather than globally.

§Example

use concurrent_sharded_stack::{ConcurrentShardedStack, PopError};

let stack = ConcurrentShardedStack::with_concurrency(4);
stack.push(1).unwrap();
stack.push(2).unwrap();

assert_eq!(stack.pop().unwrap(), 2);
assert_eq!(stack.pop().unwrap(), 1);
assert_eq!(stack.pop(), Err(PopError::Empty));

Structs§

ConcurrentShardedStack
Concurrent sharded Treiber stack.

Enums§

PopError
PushError