pub struct ConcurrentShardedStack<T: Send + 'static> { /* private fields */ }Expand description
A value-owning concurrent stack with LIFO ordering within each shard.
Delegates linking, XOR probing, closing and epoch reclamation to
concurrent-intrusive-collections. A private node allocation stores each
value. A successful pop moves out the value immediately; only the empty node
allocation waits for the epoch grace period. No intrusive API is exposed.
Empty describes a scan, not a global snapshot. Close takes effect per shard.
Values may be sent to another thread, but need not be shareable by reference:
use std::cell::Cell;
use concurrent_sharded_stack::ConcurrentShardedStack;
let stack = ConcurrentShardedStack::new();
stack.push(Cell::new(7)).unwrap();
assert_eq!(stack.pop().unwrap().get(), 7);Implementations§
Source§impl<T: Send + 'static> ConcurrentShardedStack<T>
impl<T: Send + 'static> ConcurrentShardedStack<T>
Sourcepub fn with_concurrency(shard_count: usize) -> Self
pub fn with_concurrency(shard_count: usize) -> Self
Sourcepub fn push(&self, value: T) -> Result<(), PushError<T>>
pub fn push(&self, value: T) -> Result<(), PushError<T>>
Pushes a value to this thread’s shard, or returns it if that shard is closed.
Sourcepub fn pop(&self) -> Result<T, PopError>
pub fn pop(&self) -> Result<T, PopError>
Removes and returns one owned value, scanning local then XOR-ordered shards.
A successful pop takes the payload exactly once while the node is pinned.
With active producers, retry Empty; it is not a completion signal.
Sourcepub fn close(&self) -> bool
pub fn close(&self) -> bool
Closes every shard, preserving queued values for draining.
Returns whether this call closed at least one shard. Concurrent callers may both return true. After return all subsequent pushes are rejected.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Returns the number of shards.