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§
- GLock
- Represents a granular lock object. A
GLock
is used to protect a data value of typeT
, which can only be accessed with a mutable reference after callinglock_exclusive()
,try_lock_exclusive()
,lock_exclusive_using_parent()
ortry_lock_exclusive_using_parent()
. - GLock
Builder - A
GLockBuilder
can be used to construct nestedGLock
s. In Rust, innerstruct
s are initialized before their outer containerstruct
s. Inglock
, parent lock kernels must be initialized before child lock kernels. To resolve this, aGLockBuilder
can be used to initialize the parent lock kernel first, then accept the containingstruct
inbuild()
. - GLock
Guard - 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 theGLockGuard
object. - GLock
Guard Mut - A
GLockGuard
represents an acquiredExclusive
lock instance. It can be used to read as well as mutate the protected data. The lock is released by dropping theGLockGuardMut
object.
Enums§
Type Aliases§
- Lock
Result - A type alias for
Result<T, LockError>
.