pub struct RawSpinlock { /* private fields */ }
Expand description
Provides mutual exclusion based on spinning on an AtomicBool
.
It’s recommended to use this type either combination with lock_api::Mutex
or
through the Spinlock
type.
§Example
use lock_api::RawMutex;
let lock = spinning_top::RawSpinlock::INIT;
assert_eq!(lock.try_lock(), true); // lock it
assert_eq!(lock.try_lock(), false); // can't be locked a second time
unsafe { lock.unlock(); } // unlock it
assert_eq!(lock.try_lock(), true); // now it can be locked again
Trait Implementations§
Source§impl Debug for RawSpinlock
impl Debug for RawSpinlock
Source§impl RawMutex for RawSpinlock
impl RawMutex for RawSpinlock
Source§const INIT: RawSpinlock = _
const INIT: RawSpinlock = _
Initial value for an unlocked mutex.
Source§type GuardMarker = GuardSend
type GuardMarker = GuardSend
Marker type which determines whether a lock guard should be
Send
. Use
one of the GuardSend
or GuardNoSend
helper types here.Auto Trait Implementations§
impl !Freeze for RawSpinlock
impl RefUnwindSafe for RawSpinlock
impl Send for RawSpinlock
impl Sync for RawSpinlock
impl Unpin for RawSpinlock
impl UnwindSafe for RawSpinlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more