1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
//! Crossbeam supports concurrent programming, especially focusing on memory //! management, synchronization, and non-blocking data structures. //! //! Crossbeam consists of several submodules: //! //! - `atomic` for **enhancing `std::sync` API**. `AtomicConsume` provides //! C/C++11-style "consume" atomic operations (re-exported from //! [`crossbeam-utils`]). `ArcCell` provides atomic storage and retrieval of //! `Arc`. //! //! - `utils` and `thread` for **utilities**, re-exported from [`crossbeam-utils`]. //! The "scoped" thread API in `thread` makes it possible to spawn threads that //! share stack data with their parents. The `utils::CachePadded` struct 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. //! //! - `epoch` for **memory management**, re-exported from [`crossbeam-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 from [`crossbeam-channel`]), deques //! (re-exported from [`crossbeam-deque`]), queues, and stacks. Ultimately the //! goal is to also include bags, sets and maps. #![warn(missing_docs)] #![warn(missing_debug_implementations)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "nightly", feature(alloc))] #![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] #![cfg_attr(feature = "nightly", feature(integer_atomics))] #[macro_use] extern crate cfg_if; #[cfg(feature = "std")] extern crate core; cfg_if! { if #[cfg(feature = "nightly")] { extern crate alloc; } else { mod alloc { extern crate std; pub use self::std::*; } } } mod _epoch { pub extern crate crossbeam_epoch; } #[doc(inline)] pub use _epoch::crossbeam_epoch as epoch; mod arc_cell; extern crate crossbeam_utils; /// Additional utilities for atomics. pub mod atomic { pub use arc_cell::ArcCell; pub use crossbeam_utils::atomic::AtomicCell; pub use crossbeam_utils::atomic::AtomicConsume; } /// Utilities for concurrent programming. /// /// See [the `crossbeam-utils` crate](https://github.com/crossbeam-rs/crossbeam-utils) for more /// information. pub mod utils { pub use crossbeam_utils::CachePadded; } cfg_if! { if #[cfg(feature = "std")] { pub use crossbeam_utils::thread; // Export `crossbeam_utils::thread::scope` into the crate root because it's become an // established pattern. pub use crossbeam_utils::thread::scope; mod _deque { pub extern crate crossbeam_deque; } #[doc(inline)] pub use _deque::crossbeam_deque as deque; mod _channel { pub extern crate crossbeam_channel; pub use self::crossbeam_channel::*; } #[doc(inline)] pub use _channel::crossbeam_channel as channel; // HACK(stjepang): This is the only way to reexport `select!` in Rust older than 1.30.0 #[doc(hidden)] pub use _channel::*; #[macro_use] extern crate lazy_static; extern crate num_cpus; extern crate parking_lot; mod ms_queue; mod seg_queue; mod sharded_lock; mod treiber_stack; mod wait_group; /// Concurrent queues. pub mod queue { pub use ms_queue::MsQueue; pub use seg_queue::SegQueue; } /// Concurrent stacks. pub mod stack { pub use treiber_stack::TreiberStack; } /// Utilities for thread synchronization. pub mod sync { pub use crossbeam_utils::sync::Parker; pub use sharded_lock::{ShardedLock, ShardedLockReadGuard, ShardedLockWriteGuard}; pub use wait_group::WaitGroup; } } }