crossbeam

A collection of tools for lock-free and concurrent programming in Rust: channels, deques, epoch-based GC, and more

Library
Cargo
v0.8.4
8,553stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity92
Maintenance96
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture85
Code Quality88
Innovation80
Learning Curve72

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 of std::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) via crossbeam::queue
  • Scoped threads (crossbeam::scope) that can safely borrow stack-local, non-'static data
  • Additional primitives: AtomicCell, CachePadded, Backoff, ShardedLock, and WaitGroup

Common Use Cases

  • Replacing std::sync::mpsc with crossbeam-channel for 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/'static bounds, via crossbeam::scope
  • Coordinating parallel computation completion with WaitGroup or reducing cache contention with CachePadded

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search