Lines Matching defs:Guard
174 pub fn lock(&self) -> Guard<'_, T, B> {
179 unsafe { Guard::new(self, state) }
188 pub fn try_lock(&self) -> Option<Guard<'_, T, B>> {
191 unsafe { B::try_lock(self.state.get()).map(|state| Guard::new(self, state)) }
201 pub struct Guard<'a, T: ?Sized, B: Backend> {
207 // SAFETY: `Guard` is sync when the data protected by the lock is also sync.
208 unsafe impl<T: Sync + ?Sized, B: Backend> Sync for Guard<'_, T, B> {}
210 impl<'a, T: ?Sized, B: Backend> Guard<'a, T, B> {
215 /// The following example shows how to use [`Guard::lock_ref()`] to assert the corresponding
219 /// # use kernel::{new_spinlock, sync::lock::{Backend, Guard, Lock}};
222 /// fn assert_held<T, B: Backend>(guard: &Guard<'_, T, B>, lock: &Lock<T, B>) {
278 impl<T: ?Sized, B: Backend> core::ops::Deref for Guard<'_, T, B> {
288 impl<T: ?Sized, B: Backend> core::ops::DerefMut for Guard<'_, T, B>
299 impl<T: ?Sized, B: Backend> Drop for Guard<'_, T, B> {
307 impl<'a, T: ?Sized, B: Backend> Guard<'a, T, B> {