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#![doc(test(
42    no_crate_inject,
43    attr(
44        deny(warnings, rust_2018_idioms),
45        allow(dead_code, unused_assignments, unused_variables)
46    )
47))]
48#![warn(
49    missing_docs,
50    missing_debug_implementations,
51    rust_2018_idioms,
52    unreachable_pub
53)]
54#![cfg_attr(not(feature = "std"), no_std)]
55
56pub use crossbeam_utils::atomic;
57
58pub mod utils {
59    //! Miscellaneous utilities.
60    //!
61    //! * [`Backoff`], for exponential backoff in spin loops.
62    //! * [`CachePadded`], for padding and aligning a value to the length of a cache line.
63
64    pub use crossbeam_utils::Backoff;
65    pub use crossbeam_utils::CachePadded;
66}
67
68#[cfg(feature = "alloc")]
69#[doc(inline)]
70pub use {crossbeam_epoch as epoch, crossbeam_queue as queue};
71
72#[cfg(feature = "std")]
73#[doc(inline)]
74pub use {
75    crossbeam_channel as channel, crossbeam_channel::select, crossbeam_deque as deque,
76    crossbeam_utils::sync,
77};
78
79#[cfg(feature = "std")]
80#[cfg(not(crossbeam_loom))]
81pub use crossbeam_utils::thread::{self, scope};