Crossbeam
This crate provides a set of tools for concurrent programming:
-
Atomics
ArcCell<T>is a shared mutableArc<T>pointer.AtomicCell<T>is equivalent toCell<T>, except it is also thread-safe.AtomicConsumeallows reading from primitive atomic types with "consume" ordering.
-
Data structures
dequemodule contains work-stealing deques for building task schedulers.MsQueue<T>andSegQueue<T>are simple concurrent queues.TreiberStack<T>is a lock-free stack.
-
Synchronization
channelmodule contains multi-producer multi-consumer channels for message passing.ShardedLock<T>is likeRwLock<T>, but sharded for faster concurrent reads.WaitGroupenables threads to synchronize the beginning or end of some computation.
-
Memory management
epochmodule contains epoch-based garbage collection.
-
Utilities
CachePadded<T>pads and aligns a value to the length of a cache line.scope()can spawn threads that borrow local variables from the stack.
Crates
Some of the tools live in the main crossbeam crate, and some are re-exported
from smaller subcrates:
crossbeam-channelprovides multi-producer multi-consumer channels for message passing.crossbeam-dequeprovides work-stealing deques, which are primarily intended for building task schedulers.crossbeam-epochprovides epoch-based garbage collection for building concurrent data structures.crossbeam-utilsprovides miscellaneous utilities for concurrent programming:
Take a look at src/lib.rs to see what goes where.
There is one more experimental subcrate that is not yet included in crossbeam:
crossbeam-skiplistprovides concurrent maps and sets based on lock-free skip lists.
Usage
Add this to your Cargo.toml:
[]
= "0.6"
Next, add this to your crate:
extern crate crossbeam;
Compatibility
The minimum supported Rust version is 1.26.
Features available in no_std environments:
AtomicCell<T>AtomicConsumeCachePadded<T>epoch(nightly Rust only)
Contributing
Crossbeam welcomes contribution from everyone in the form of suggestions, bug reports, pull requests, and feedback. 💛
If you're looking for things to do, there are several easy ways to get started:
- Found a bug or have a feature request? Tell us!
- Issues and PRs labeled with feedback wanted need feedback from users and contributors.
- Issues labeled with good first issue are relatively easy starter issues.
RFCs
We also have the RFCs repository for more high-level discussion. It is a place where we brainstorm ideas and propose substantial changes to Crossbeam.
Feel free to participate in any open issues or pull requests!
Learning resources
If you'd like to learn more about concurrency and non-blocking data structures, there's a list of learning resources in our wiki, which includes related blog posts, papers, videos, and other similar projects.
Another good place to visit is merged RFCs. They contain elaborate descriptions and rationale for features we've introduced to Crossbeam, but note that some of the written information is now out of date.
Conduct
The Crossbeam project adheres to the Rust Code of Conduct. This describes the minimum behavior expected from all contributors.
License
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.
Some Crossbeam subcrates have additional licensing notices. Take a look at other readme files in this repository for more information.
Contribution
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.