summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorJon Gjengset <jon@thesquareplanet.com>2019-04-18 13:16:26 -0400
committerLucio Franco <luciofranco14@gmail.com>2019-04-18 13:16:26 -0400
commitcf0662199822c848b376db4973c7dbae30303c4e (patch)
treec98dbbb065e96d365d8f44a64eda416bf6cdff68 /tokio
parent7e51ab05e95cef00204ab18523de45f37d9687d3 (diff)
tokio-sync: Add async mutual exclusion primitive (#964)
This PR introduces `Lock`: A concurrency primitive built on top of `Semaphore` that provides a `Mutex`-like primitive that interacts nicely with futures. Specifically, `LockGuard` (in contrast to `MutexGuard`) does _not_ borrow the `Lock`, and can thus be passed into a future where it will later be unlocked. This replaces #958, which attempted to introduce a less generic version. The primitive proposed there will instead live in [`async-lease`](https://github.com/jonhoo/async-lease).
Diffstat (limited to 'tokio')
-rw-r--r--tokio/Cargo.toml2
-rw-r--r--tokio/src/sync.rs3
2 files changed, 3 insertions, 2 deletions
diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml
index c2792971..e2901c3c 100644
--- a/tokio/Cargo.toml
+++ b/tokio/Cargo.toml
@@ -73,7 +73,7 @@ tokio-fs = { version = "0.1.6", optional = true }
tokio-io = { version = "0.1.6", optional = true }
tokio-executor = { version = "0.1.7", optional = true }
tokio-reactor = { version = "0.1.1", optional = true }
-tokio-sync = { version = "0.1.3", optional = true }
+tokio-sync = { version = "0.1.3", optional = true, path = "../tokio-sync" }
tokio-threadpool = { version = "0.1.13", optional = true }
tokio-tcp = { version = "0.1.0", optional = true }
tokio-udp = { version = "0.1.0", optional = true }
diff --git a/tokio/src/sync.rs b/tokio/src/sync.rs
index ff7438a2..c8fb7524 100644
--- a/tokio/src/sync.rs
+++ b/tokio/src/sync.rs
@@ -9,7 +9,8 @@
//! from one task to another.
//! - [mpsc](mpsc/index.html), a multi-producer, single-consumer channel for
//! sending values between tasks.
+//! - [lock](lock/index.html), an asynchronous `Mutex`-like type.
//! - [watch](watch/index.html), a single-producer, multi-consumer channel that
//! only stores the **most recently** sent value.
-pub use tokio_sync::{mpsc, oneshot, watch};
+pub use tokio_sync::{lock, mpsc, oneshot, watch};