pub enum LockType {
IntentionShared,
IntentionExclusive,
Shared,
SharedIntentionExclusive,
Exclusive,
}
Expand description
The type of lock that can be acquired for a GLock
.
Variants§
Before a Shared
lock is acquired for a child GLock
, IntentionShared
locks must be
acquired for each of its ancestors.
Compatibility
IntentionShared
: Yes
IntentionExclusive
: Yes
Shared
: Yes
SharedIntentionExclusive
: Yes
Exclusive
: No
IntentionExclusive
Before an Exclusive
or SharedIntentionExclusive
lock is acquired for a child GLock
,
IntentionExclusive
locks must be acquired for each of its ancestors.
Compatibility
IntentionShared
: Yes
IntentionExclusive
: Yes
Shared
: No
SharedIntentionExclusive
: No
Exclusive
: No
A Shared
lock grants read access to its protected data. Before acquiring a Shared
lock for a
child GLock
, IntentionShared
(or more restrictive) locks must be acquired for all its ancestors.
Compatibility
IntentionShared
: Yes
IntentionExclusive
: No
Shared
: Yes
SharedIntentionExclusive
: No
Exclusive
: No
A SharedIntentionExclusive
lock - as the name implies - is similar to holding both a
Shared
lock and an IntentionExclusive
lock at the same time. Before acquiring a
SharedIntentionExclusive
lock for a child GLock
, IntentionExclusive
(or more
restrictive) locks must be acquired for all its ancestors.
Compatibility
IntentionShared
: Yes
IntentionExclusive
: No
Shared
: No
SharedIntentionExclusive
: No
Exclusive
: No
Exclusive
An Exclusive
lock grants write access to its protected data. Before acquiring an
Exclusive
lock for a child GLock
, IntentionExclusive
(or more restrictive) locks
must be acquired for all its ancestors.
Compatibility
IntentionShared
: No
IntentionExclusive
: No
Shared
: No
SharedIntentionExclusive
: No
Exclusive
: No
Implementations§
source§impl LockType
impl LockType
pub fn lock_types() -> &'static [LockType]
sourcepub fn implicit_parent_type(self) -> LockType
pub fn implicit_parent_type(self) -> LockType
Returns the implicit parent lock type for this lock type. This means that, before acquiring
this type of lock for a child GLock
, locks of the implicit parent type must be acquired
for all its ancestor GLock
s.
sourcepub fn compatible_with(self, other_type: LockType) -> bool
pub fn compatible_with(self, other_type: LockType) -> bool
Returns true
if the lock type is compatible with the specified lock type, false
otherwise.
sourcepub fn upgradable_to(self, other_type: LockType) -> bool
pub fn upgradable_to(self, other_type: LockType) -> bool
Returns true
if the lock type is upgradable to the specified lock type, false
otherwise.
sourcepub fn supports_children(self, other_type: LockType) -> bool
pub fn supports_children(self, other_type: LockType) -> bool
Returns true
if the lock type can support child locks of the specified type, false
otherwise.
If true
, this means that if a lock of this type is acquired for a parent GLock
, a lock
of the specified type can be acquired for a child GLock
.
sourcepub fn min_upgradable(self, other_type: LockType) -> LockType
pub fn min_upgradable(self, other_type: LockType) -> LockType
Returns the least restrictive lock type that this lock type can be upgraded to, that is at least as restrictive as the specified type.