diff options
author | Carl Lerche <me@carllerche.com> | 2019-10-29 15:11:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 15:11:31 -0700 |
commit | 2b909d6805990abf0bc2a5dea9e7267ff87df704 (patch) | |
tree | de255969c720c294af754b3840efabff3e6d69a0 /tokio/src/sync/mod.rs | |
parent | c62ef2d232dea1535a8e22484fa2ca083f03e903 (diff) |
sync: move into `tokio` crate (#1705)
A step towards collapsing Tokio sub crates into a single `tokio`
crate (#1318).
The sync implementation is now provided by the main `tokio` crate.
Functionality can be opted out of by using the various net related
feature flags.
Diffstat (limited to 'tokio/src/sync/mod.rs')
-rw-r--r-- | tokio/src/sync/mod.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tokio/src/sync/mod.rs b/tokio/src/sync/mod.rs new file mode 100644 index 00000000..84f6bd98 --- /dev/null +++ b/tokio/src/sync/mod.rs @@ -0,0 +1,58 @@ +//! Future-aware synchronization +//! +//! This module is enabled with the **`sync`** feature flag. +//! +//! Tasks sometimes need to communicate with each other. This module contains +//! two basic abstractions for doing so: +//! +//! - [oneshot](oneshot/index.html), a way of sending a single value +//! from one task to another. +//! - [mpsc](mpsc/index.html), a multi-producer, single-consumer channel for +//! sending values between tasks. +//! - [`Mutex`](struct.Mutex.html), an asynchronous `Mutex`-like type. +//! - [watch](watch/index.html), a single-producer, multi-consumer channel that +//! only stores the **most recently** sent value. + +macro_rules! debug { + ($($t:tt)*) => { + if false { + println!($($t)*); + } + } +} + +macro_rules! if_loom { + ($($t:tt)*) => {{ + #[cfg(loom)] + const LOOM: bool = true; + #[cfg(not(loom))] + const LOOM: bool = false; + + if LOOM { + $($t)* + } + }} +} + +mod barrier; +pub use barrier::{Barrier, BarrierWaitResult}; + +mod loom; + +pub mod mpsc; + +mod mutex; +pub use mutex::{Mutex, MutexGuard}; + +pub mod oneshot; + +pub mod semaphore; + +mod task; +pub use task::AtomicWaker; + +pub mod watch; + +/// Unit tests +#[cfg(test)] +mod tests; |