Struct spinning_top::RawSpinlock[][src]

pub struct RawSpinlock { /* fields omitted */ }
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

impl Debug for RawSpinlock[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl RawMutex for RawSpinlock[src]

const INIT: RawSpinlock[src]

Initial value for an unlocked mutex.

type GuardMarker = GuardSend

Marker type which determines whether a lock guard should be Send. Use one of the GuardSend or GuardNoSend helper types here. Read more

fn lock(&self)[src]

Acquires this mutex, blocking the current thread until it is able to do so.

fn try_lock(&self) -> bool[src]

Attempts to acquire this mutex without blocking. Returns true if the lock was successfully acquired and false otherwise. Read more

unsafe fn unlock(&self)[src]

Unlocks this mutex. Read more

fn is_locked(&self) -> bool[src]

Checks whether the mutex is currently locked.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.