Files
tokio/tokio/src/sync/mod.rs
T

58 lines
1.3 KiB
Rust
Raw Normal View History

#![cfg_attr(loom, allow(dead_code, unreachable_pub, unused_imports))]
//! 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.
2019-11-18 07:00:55 -08:00
cfg_sync! {
mod barrier;
pub use barrier::{Barrier, BarrierWaitResult};
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
pub mod mpsc;
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
mod mutex;
pub use mutex::{Mutex, MutexGuard};
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
pub mod oneshot;
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
pub(crate) mod semaphore;
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
mod task;
pub(crate) use task::AtomicWaker;
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
pub mod watch;
}
2019-10-29 15:11:31 -07:00
2019-11-18 07:00:55 -08:00
cfg_not_sync! {
cfg_resource_drivers! {
2019-11-18 07:00:55 -08:00
mod task;
pub(crate) use task::AtomicWaker;
}
2019-10-29 15:11:31 -07:00
2019-11-22 15:55:10 -08:00
#[cfg(any(
feature = "rt-core",
feature = "process",
feature = "signal"))]
pub(crate) mod oneshot;
2019-11-18 07:00:55 -08:00
cfg_signal! {
pub(crate) mod mpsc;
pub(crate) mod semaphore;
}
}
2019-10-29 15:11:31 -07:00
/// Unit tests
#[cfg(test)]
mod tests;