Crate glock

source ·
Expand description

Granular locking crate for Rust. Instead of using coarse-grained Mutex or RwLock which can be used to lock an entire structure, glock provides more granular locking.

Code is hosted on github.com:

git clone https://github.com/aymanmadkour/glock

Structs

Represents a granular lock object. A GLock is used to protect a data value of type T, which can only be accessed with a mutable reference after calling lock_exclusive(), try_lock_exclusive(), lock_exclusive_using_parent() or try_lock_exclusive_using_parent().
A GLockBuilder can be used to construct nested GLocks. In Rust, inner structs are initialized before their outer container structs. In glock, parent lock kernels must be initialized before child lock kernels. To resolve this, a GLockBuilder can be used to initialize the parent lock kernel first, then accept the containing struct in build().
A GLockGuard represents an acquired lock instance of any type. It can be used to access the protected data. The lock is released by dropping the GLockGuard object.
A GLockGuard represents an acquired Exclusive lock instance. It can be used to read as well as mutate the protected data. The lock is released by dropping the GLockGuardMut object.

Enums

Error enum for glock crate.
The type of lock that can be acquired for a GLock.

Type Definitions

A type alias for Result<T, LockError>.