1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
//! An unsafe (non-thread-safe) lock, equivalent to UnsafeCell
use core::marker::PhantomData;
use lock_api::{GuardSend, RawMutex};
/// An unsafe (non-thread-safe) lock, equivalent to UnsafeCell
#[derive(Debug)]
pub struct NoopLock {
/// Assigned in order to make the type !Sync
_phantom: PhantomData<*mut ()>,
}
unsafe impl RawMutex for NoopLock {
const INIT: NoopLock = NoopLock {
_phantom: PhantomData,
};
type GuardMarker = GuardSend;
fn lock(&self) {}
fn try_lock(&self) -> bool {
true
}
unsafe fn unlock(&self) {}
}