summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/mod.rs
blob: 3ee563c3657394dec4c04163092d327d9ae078da (plain)
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
//! 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.

cfg_sync! {
    mod barrier;
    pub use barrier::{Barrier, BarrierWaitResult};

    pub mod mpsc;

    mod mutex;
    pub use mutex::{Mutex, MutexGuard};

    pub mod oneshot;

    pub(crate) mod semaphore;

    mod task;
    pub(crate) use task::AtomicWaker;

    pub mod watch;
}

cfg_not_sync! {
    cfg_atomic_waker! {
        mod task;
        pub(crate) use task::AtomicWaker;
    }

    cfg_rt_threaded! {
        pub(crate) mod oneshot;
    }

    cfg_signal! {
        pub(crate) mod mpsc;
        pub(crate) mod semaphore;

        cfg_not_rt_threaded! {
            pub(crate) mod oneshot;
        }
    }
}

/// Unit tests
#[cfg(test)]
mod tests;