guardian

Crates.ioguardian
lib.rsguardian
version1.1.0
sourcesrc
created_at2016-06-21 16:58:29.87826
updated_at2023-12-17 10:37:00.631044
descriptionProvides owned mutex guards for refcounted mutexes.
homepagehttps://github.com/jonhoo/guardian
repositoryhttps://github.com/jonhoo/guardian.git
max_upload_size
id5445
size53,719
Jon Gjengset (jonhoo)

documentation

README

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.

Commit count: 15

cargo fmt