Skip to main content

crossbeam/
lib.rs

1//! Tools for concurrent programming.
2//!
3//! ## Atomics
4//!
5//! * [`AtomicCell`], a thread-safe mutable memory location.
6//! * [`AtomicConsume`], for reading from primitive atomic types with "consume" ordering.
7//!
8//! ## Data structures
9//!
10//! * [`deque`], work-stealing deques for building task schedulers.
11//! * [`ArrayQueue`], a bounded MPMC queue that allocates a fixed-capacity buffer on construction.
12//! * [`SegQueue`], an unbounded MPMC queue that allocates small buffers, segments, on demand.
13//!
14//! ## Memory management
15//!
16//! * [`epoch`], an epoch-based garbage collector.
17//!
18//! ## Thread synchronization
19//!
20//! * [`channel`], multi-producer multi-consumer channels for message passing.
21//! * [`Parker`], a thread parking primitive.
22//! * [`ShardedLock`], a sharded reader-writer lock with fast concurrent reads.
23//! * [`WaitGroup`], for synchronizing the beginning or end of some computation.
24//!
25//! ## Utilities
26//!
27//! * [`Backoff`], for exponential backoff in spin loops.
28//! * [`CachePadded`], for padding and aligning a value to the length of a cache line.
29//! * [`scope`], for spawning threads that borrow local variables from the stack.
30//!
31//! [`AtomicCell`]: atomic::AtomicCell
32//! [`AtomicConsume`]: atomic::AtomicConsume
33//! [`ArrayQueue`]: queue::ArrayQueue
34//! [`SegQueue`]: queue::SegQueue
35//! [`Parker`]: sync::Parker
36//! [`ShardedLock`]: sync::ShardedLock
37//! [`WaitGroup`]: sync::WaitGroup
38//! [`Backoff`]: utils::Backoff
39//! [`CachePadded`]: utils::CachePadded
40
41#![no_std]
42#![doc(test(
43    no_crate_inject,
44    attr(
45        deny(warnings, rust_2018_idioms),
46        allow(dead_code, unused_assignments, unused_variables)
47    )
48))]
49#![warn(
50    missing_docs,
51    missing_debug_implementations,
52    rust_2018_idioms,
53    unreachable_pub
54)]
55
56#[cfg(feature = "std")]
57extern crate std;
58
59pub use crossbeam_utils::atomic;
60
61pub mod utils {
62    //! Miscellaneous utilities.
63    //!
64    //! * [`Backoff`], for exponential backoff in spin loops.
65    //! * [`CachePadded`], for padding and aligning a value to the length of a cache line.
66
67    pub use crossbeam_utils::Backoff;
68    pub use crossbeam_utils::CachePadded;
69}
70
71#[cfg(feature = "alloc")]
72#[doc(inline)]
73pub use {crossbeam_epoch as epoch, crossbeam_queue as queue};
74
75#[cfg(feature = "std")]
76#[doc(inline)]
77pub use {
78    crossbeam_channel as channel, crossbeam_channel::select, crossbeam_deque as deque,
79    crossbeam_utils::sync,
80};
81
82#[cfg(feature = "std")]
83#[cfg(not(crossbeam_loom))]
84pub use crossbeam_utils::thread::{self, scope};