Skip to content

Commit

Permalink
sync: adds Notify for basic task notification (#2210)
Browse files Browse the repository at this point in the history
`Notify` provides a synchronization primitive similar to thread park /
unpark, except for tasks.
  • Loading branch information
carllerche authored Feb 26, 2020
1 parent 7207bf3 commit 8b7ea0f
Show file tree
Hide file tree
Showing 8 changed files with 1,211 additions and 0 deletions.
1 change: 1 addition & 0 deletions tokio/src/loom/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub(crate) mod sync {
pub(crate) use crate::loom::std::atomic_u64::AtomicU64;
pub(crate) use crate::loom::std::atomic_usize::AtomicUsize;

pub(crate) use std::sync::atomic::AtomicU8;
pub(crate) use std::sync::atomic::{fence, AtomicPtr};
pub(crate) use std::sync::atomic::{spin_loop_hint, AtomicBool};
}
Expand Down
12 changes: 12 additions & 0 deletions tokio/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,18 @@
//! * [`Mutex`][Mutex] Mutual Exclusion mechanism, which ensures that at most
//! one thread at a time is able to access some data.
//!
//! * [`Notify`][Notify] Basic task notification. `Notify` supports notifying a
//! receiving task without sending data. In this case, the task wakes up and
//! resumes processing.
//!
//! * [`RwLock`][RwLock] Provides a mutual exclusion mechanism which allows
//! multiple readers at the same time, while allowing only one writer at a
//! time. In some cases, this can be more efficient than a mutex.
//!
//! * [`Semaphore`][Semaphore] Limits the amount of concurrency. A semaphore
//! holds a number of permits, which tasks may request in order to enter a
//! critical section. Semaphores are useful for implementing limiting of
//! bounding of any kind.
cfg_sync! {
mod barrier;
Expand All @@ -421,6 +430,9 @@ cfg_sync! {
mod mutex;
pub use mutex::{Mutex, MutexGuard};

mod notify;
pub use notify::Notify;

pub mod oneshot;

pub(crate) mod semaphore_ll;
Expand Down
Loading

0 comments on commit 8b7ea0f

Please sign in to comment.