Struct glock::GLockGuard
source · pub struct GLockGuard<'lck, T: 'lck> { /* private fields */ }
Expand description
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.
Implementations§
source§impl<'lck, T: 'lck> GLockGuard<'lck, T>
impl<'lck, T: 'lck> GLockGuard<'lck, T>
sourcepub fn lock_type(&self) -> LockResult<LockType>
pub fn lock_type(&self) -> LockResult<LockType>
Returns the type of the lock currently held.
sourcepub fn upgrade(&self, to_type: LockType) -> LockResult<()>
pub fn upgrade(&self, to_type: LockType) -> LockResult<()>
Upgrades the type of this GLockGuard
to the specified type. If parent lock does not support
the new type, it will be upgraded as well. If the lock is currently busy, it will block until
it is ready.
sourcepub fn try_upgrade(&self, to_type: LockType) -> LockResult<()>
pub fn try_upgrade(&self, to_type: LockType) -> LockResult<()>
Attempts to upgrade the type of this GLockGuard
to the specified type. If parent lock
does not support the new type, it will be upgraded as well. If the lock is currently busy,
it will return a LockError::LockBusy
error.
sourcepub fn upgrade_to_exclusive(
self
) -> Result<GLockGuardMut<'lck, T>, (LockError, GLockGuard<'lck, T>)>
pub fn upgrade_to_exclusive(
self
) -> Result<GLockGuardMut<'lck, T>, (LockError, GLockGuard<'lck, T>)>
Upgrades the type of this GLockGuard
to Exclusive
. If parent lock does not support
the new type, it will be upgraded as well. If the lock is currently busy, it will block until
it is ready.
This method consumes the current GLockGuard
and returns a new GLockGuardMut
.
In case of failure, it will return a tuple containing the error as well as the original
GLockGuard
.
sourcepub fn try_upgrade_to_exclusive(
self
) -> Result<GLockGuardMut<'lck, T>, (LockError, GLockGuard<'lck, T>)>
pub fn try_upgrade_to_exclusive(
self
) -> Result<GLockGuardMut<'lck, T>, (LockError, GLockGuard<'lck, T>)>
Attempts to upgrade the type of this GLockGuard
to Exclusive
. If parent lock does not support
the new type, it will be upgraded as well. If the lock is currently busy, If the lock is
currently busy, it will return a LockError::LockBusy
error.
This method consumes the current GLockGuard
and returns a new GLockGuardMut
.
In case of failure, it will return a tuple containing the error as well as the original
GLockGuard
.