]> git.proxmox.com Git - rustc.git/blob - vendor/crossbeam/src/lib.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / vendor / crossbeam / src / 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
56 pub use crossbeam_utils::atomic;
57
58 pub 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 use cfg_if::cfg_if;
69
70 cfg_if! {
71 if #[cfg(feature = "alloc")] {
72 #[doc(inline)]
73 pub use crossbeam_epoch as epoch;
74
75 #[doc(inline)]
76 pub use crossbeam_queue as queue;
77 }
78 }
79
80 cfg_if! {
81 if #[cfg(feature = "std")] {
82 #[doc(inline)]
83 pub use crossbeam_deque as deque;
84
85 #[doc(inline)]
86 pub use crossbeam_channel as channel;
87 pub use crossbeam_channel::select;
88
89 pub use crossbeam_utils::sync;
90
91 #[cfg(not(crossbeam_loom))]
92 pub use crossbeam_utils::thread;
93 #[cfg(not(crossbeam_loom))]
94 pub use crossbeam_utils::thread::scope;
95 }
96 }