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

Formats the value using the given formatter. Read more

Initial value for an unlocked mutex.

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

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

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

Unlocks this mutex. Read more

Checks whether the mutex is currently locked.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.