Crossbeam supports concurrent programming, especially focusing on memory management, synchronization, and non-blocking data structures.
Crossbeam consists of several submodules:
-
atomicfor enhancingstd::syncAPI.AtomicConsumeprovides C/C++11-style "consume" atomic operations (re-exported fromcrossbeam-utils).ArcCellprovides atomic storage and retrieval ofArc. -
utilsandthreadfor utilities, re-exported fromcrossbeam-utils. The "scoped" thread API inthreadmakes it possible to spawn threads that share stack data with their parents. Theutils::CachePaddedstruct inserts padding to align data with the size of a cacheline. This crate also seeks to expand the standard library's few synchronization primitives (locks, barriers, etc) to include advanced/niche primitives, as well as userspace alternatives. -
epochfor memory management, re-exported fromcrossbeam-epoch. Because non-blocking data structures avoid global synchronization, it is not easy to tell when internal data can be safely freed. The crate provides generic, easy to use, and high-performance APIs for managing memory in these cases. We plan to support other memory management schemes, e.g. hazard pointers (HP) and quiescent state-based reclamation (QSBR). -
Concurrent data structures which are non-blocking and much superior to wrapping sequential ones with a
Mutex. Crossbeam currently provides channels (re-exported fromcrossbeam-channel), deques (re-exported fromcrossbeam-deque), queues, and stacks. Ultimately the goal is to also include bags, sets and maps.
Add this to your Cargo.toml:
[dependencies]
crossbeam = "0.5"Next, add this to your crate:
extern crate crossbeam;The minimum required Rust version is 1.26.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.