7 releases (stable)

1.2.0 Aug 6, 2024
1.1.0 Dec 17, 2023
1.0.2 Mar 7, 2022
1.0.1 Dec 4, 2018
0.3.0 Jun 21, 2016

#87 in Concurrency

Download history 810/week @ 2024-08-10 574/week @ 2024-08-17 1137/week @ 2024-08-24 861/week @ 2024-08-31 874/week @ 2024-09-07 1079/week @ 2024-09-14 1303/week @ 2024-09-21 1183/week @ 2024-09-28 1113/week @ 2024-10-05 1613/week @ 2024-10-12 1884/week @ 2024-10-19 1596/week @ 2024-10-26 2535/week @ 2024-11-02 1468/week @ 2024-11-09 1472/week @ 2024-11-16 1274/week @ 2024-11-23

7,091 downloads per month
Used in 22 crates (5 directly)

MIT/Apache

36KB
478 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