pub unsafe trait Lock: for<'this> Lifetime<'this> {
fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard;
fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard;
}Expand description
A lock.
Safety
This lock must uphold XOR mutability: at any give time either one exclusive guard or multiple shared guards can be handed out.
Note that the shared implementation does not actually have to be shared; it is just an optimization for implementations that support it.
Required Methods
fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard
fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard
Acquire an exclusive lock.
When called recursively, this function must panic, abort or deadlock.
If the previous guard was dropped during a panic, this function may or may not panic.
Acquire a shared lock.
When called recursively, this function may succeed, panic, abort or deadlock.
If the previous guard was dropped during a panic, this function may or may not panic.