Skip to content

Commit

Permalink
sync: Add watch, a single value broadcast channel (tokio-rs#922)
Browse files Browse the repository at this point in the history
A single-producer, multi-consumer channel that only retains the _last_ sent
value. Values are broadcasted out.

This channel is useful for watching for changes to a value from multiple
points in the code base (for example, changes to a configuration value).
  • Loading branch information
carllerche authored Feb 23, 2019
1 parent 7039f02 commit 70f4fc4
Show file tree
Hide file tree
Showing 5 changed files with 645 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
//! from one task to another.
//! - [mpsc](mpsc/index.html), a multi-producer, single-consumer channel for
//! sending values between tasks.
//! - [watch](watch/index.html), a single-producer, multi-consumer channel that
//! only stores the **most recently** sent value.
pub use tokio_sync::{mpsc, oneshot};
pub use tokio_sync::{mpsc, oneshot, watch};
1 change: 1 addition & 0 deletions tokio-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Synchronization utilities.
categories = ["asynchronous"]

[dependencies]
fnv = "1.0.6"
futures = "0.1.19"

[dev-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions tokio-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//!
//! This crate provides primitives for synchronizing asynchronous tasks.
extern crate fnv;
#[macro_use]
extern crate futures;

macro_rules! debug {
Expand All @@ -27,3 +29,4 @@ pub mod mpsc;
pub mod oneshot;
pub mod semaphore;
pub mod task;
pub mod watch;
Loading

0 comments on commit 70f4fc4

Please sign in to comment.