pub struct SpinLockGuard<'a, T>where
T: 'a + ?Sized,{
caller: &'static Location<'static>,
lock: &'a SpinLock<T>,
guard: Option<InterruptGuard>,
}Expand description
An implementation of a “scoped lock” of a spinlock. When this structure is dropped (falls out of scope) without unlock, panic occurs.
The lock must be explicitly unlocked by unlock method.
The data protected by the mutex can be accessed through this guard.
This structure is created by the lock and try_lock methods on
SpinLock.
Fields§
§caller: &'static Location<'static>§lock: &'a SpinLock<T>§guard: Option<InterruptGuard>Implementations§
Source§impl<T> SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> SpinLockGuard<'_, T>where
T: ?Sized,
Sourcepub fn unlock(self)
pub fn unlock(self)
Releases the underlying SpinLock.
As the guard does not automatically release the lock on drop,
the caller must explicitly invoke [unlock] to mark the lock
as available again.
§Example
let lock = SpinLock::new(123);
let guard = lock.lock();
// Work with the locked data...
// Explicitly release the lock.
guard.unlock();Trait Implementations§
Source§impl<T> Deref for SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> Deref for SpinLockGuard<'_, T>where
T: ?Sized,
Source§impl<T> DerefMut for SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> DerefMut for SpinLockGuard<'_, T>where
T: ?Sized,
Source§impl<T> Drop for SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> Drop for SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> !Send for SpinLockGuard<'_, T>where
T: ?Sized,
impl<T> Sync for SpinLockGuard<'_, T>where
T: Sync + ?Sized,
Auto Trait Implementations§
impl<'a, T> Freeze for SpinLockGuard<'a, T>where
T: ?Sized,
impl<'a, T> !RefUnwindSafe for SpinLockGuard<'a, T>
impl<'a, T> Unpin for SpinLockGuard<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for SpinLockGuard<'a, T>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more