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).
This commit is contained in:
Jon Gjengset
2019-04-18 13:16:26 -04:00
committed by Lucio Franco
parent 7e51ab05e9
commit cf06621998
7 changed files with 256 additions and 3 deletions
+1
View File
@@ -24,6 +24,7 @@ macro_rules! if_fuzz {
}}
}
pub mod lock;
mod loom;
pub mod mpsc;
pub mod oneshot;