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 -1
View File
@@ -24,6 +24,6 @@ futures = "0.1.19"
[dev-dependencies]
env_logger = { version = "0.5", default-features = false }
tokio = "0.1.15"
tokio = { version = "0.1.15", path = "../tokio" }
tokio-mock-task = "0.1.1"
loom = { version = "0.1.1", features = ["futures"] }