crossbeam
A collection of tools for lock-free and concurrent programming in Rust: channels, deques, epoch-based GC, and more
Repository Health
Technical Analysis
crossbeam is the umbrella crate for a family of Rust concurrency primitives maintained under the crossbeam-rs organization, re-exporting crossbeam-channel (MPMC channels), crossbeam-deque (work-stealing deques for task schedulers), crossbeam-epoch (epoch-based garbage collection for lock-free data structures), and crossbeam-queue (bounded/unbounded lock-free queues) behind a single dependency and a curated set of module paths (channel, deque, epoch, queue, sync, atomic, utils).
Beyond re-exporting its sibling crates, the crate also provides scoped-thread support (crossbeam::scope) that lets threads safely borrow non-'static data from the stack, plus synchronization primitives like ShardedLock and WaitGroup. It is no_std-compatible at its core (with alloc/std features layered on top), making it usable in a wide range of environments from application code down to lower-level systems programming.
What You Get
- MPMC channels (
crossbeam::channel) as a fast alternative/superset ofstd::sync::mpsc - Work-stealing deques (
crossbeam::deque) for building custom task schedulers - Epoch-based garbage collection (
crossbeam::epoch) for building lock-free data structures safely - Bounded and unbounded lock-free queues (
ArrayQueue,SegQueue) viacrossbeam::queue - Scoped threads (
crossbeam::scope) that can safely borrow stack-local, non-'staticdata - Additional primitives:
AtomicCell,CachePadded,Backoff,ShardedLock, andWaitGroup
Common Use Cases
- Replacing
std::sync::mpscwithcrossbeam-channelfor faster, more flexible multi-producer multi-consumer messaging - Building custom work-stealing task schedulers or thread pools on top of
crossbeam::deque - Implementing lock-free data structures that need safe memory reclamation via
crossbeam::epoch - Spawning threads that borrow local stack data without needing
Arc/'staticbounds, viacrossbeam::scope - Coordinating parallel computation completion with
WaitGroupor reducing cache contention withCachePadded
Under The Hood
Architecture
crossbeam is a Cargo workspace umbrella crate: the root crossbeam package (src/lib.rs, 79 lines) contains almost no logic of its own — it is a curated set of pub use re-exports that stitch together crossbeam-channel, crossbeam-deque, crossbeam-epoch, crossbeam-queue, and crossbeam-utils into a single coherent module namespace (channel, deque, epoch, queue, sync, atomic, utils), with the real implementations living in each dedicated sibling crate within the same workspace.
Tech Stack
Written in Rust with #![no_std] at the core, layering alloc and std features on top so the same crate works in embedded/no-std contexts as well as full applications. Feature flags (std, alloc) propagate down to each sub-crate’s own features, giving fine-grained control over how much of the standard library a build depends on. The workspace uses loom (referenced via cfg(crossbeam_loom)) for concurrency model-checking in CI, alongside standard cargo test.
Code Quality
Because the umbrella crate is mostly re-exports, code quality is best assessed at the sibling-crate level, where each (crossbeam-channel, crossbeam-epoch, etc.) has its own extensive test suites including loom-based concurrency testing — a strong signal of rigor for lock-free/unsafe code. Workspace-wide Clippy lints (missing_debug_implementations, unreachable_pub, rust_2018_idioms) are enforced consistently across all member crates via [workspace.lints].
API Design
The umbrella crate’s entire value proposition is API ergonomics: instead of adding four or five separate crossbeam-* dependencies and remembering their names, consumers add one crossbeam dependency and get a single, well-organized module namespace (crossbeam::channel, crossbeam::deque, etc.) with doc comments in lib.rs linking directly to each primitive. This consolidation, combined with mature and widely-used sibling crates, makes the learning curve mostly about learning Rust concurrency concepts rather than the crate’s own API surface.