6 releases (stable)

1.1.0 Dec 17, 2023
1.0.2 Mar 7, 2022
1.0.1 Dec 4, 2018
1.0.0 Jan 30, 2017
0.3.0 Jun 21, 2016

#219 in Concurrency

Download history 342/week @ 2024-01-07 350/week @ 2024-01-14 40/week @ 2024-01-21 27/week @ 2024-01-28 76/week @ 2024-02-04 132/week @ 2024-02-11 39/week @ 2024-02-18 107/week @ 2024-02-25 10/week @ 2024-03-03 77/week @ 2024-03-10 27/week @ 2024-03-17 13/week @ 2024-03-24 64/week @ 2024-03-31 10/week @ 2024-04-07

118 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

25KB
326 lines

guardian

Crates.io Documentation codecov Dependency status

Guardian is a Rust library that provides owned mutex guards for refcounted mutexes.

Normally, lock guards (be it for Mutex or RwLock) are bound to the lifetime of the borrow of the underlying lock. Specifically, the function signatures all resemble: fn lock<'a>(&'a self) -> Guard<'a>.

If the mutex is refcounted using an Rc or an Arc, it is not necessary for the guard to be scoped in this way -- it could instead carry with it a ref to the mutex in question, which allows the guard to be held for as long as is necessary. This is particularly useful for writing iterators where it is advantageous to hold a read lock for the duration of the iteration.

No runtime deps