Tools for concurrent programming in Rust: channels, queues, atomics and scoped threads
open sourceMIT OR Apache-2.0free
Crossbeam is a set of Rust crates for concurrent programming. crossbeam-channel provides multi-producer multi-consumer channels for message passing, crossbeam-deque work-stealing deques for task schedulers, crossbeam-queue bounded and unbounded concurrent queues, crossbeam-epoch epoch-based garbage collection for building lock-free data structures, and crossbeam-utils atomics, synchronization primitives and scoped threads. The main crossbeam crate re-exports them, and an experimental crossbeam-skiplist adds concurrent maps and sets.
Problems it solves
- send messages between threads in Rust with more than one consumer
- build a work-stealing task scheduler in Rust
- share a lock-free queue between Rust threads
- spawn threads that borrow local variables in Rust
Features
- multi-producer multi-consumer channels (crossbeam-channel)
- work-stealing deques for task schedulers
- bounded ArrayQueue and unbounded SegQueue
- epoch-based memory reclamation for lock-free data structures
- AtomicCell, ShardedLock, Parker, WaitGroup and Backoff
- scoped threads that borrow from the stack
- many features usable in no_std environments
Limitations
Alternatives
The same job
These do what Crossbeam does.
- Rayon Simple work-stealing data parallelism for Rust
- parking_lot Compact, fast mutexes, read-write locks and condition variables for Rust
- DashMap Blazing fast concurrent HashMap for Rust
