Struct kernel::sync::SpinLock[][src]

pub struct SpinLock<T: ?Sized> { /* fields omitted */ }
Expand description

Exposes the kernel’s spinlock_t. When multiple CPUs attempt to lock the same spinlock, only one at a time is allowed to progress, the others will block (spinning) until the spinlock is unlocked, at which point another CPU will be allowed to make progress.

A SpinLock must first be initialised with a call to SpinLock::init before it can be used. The spinlock_init macro is provided to automatically assign a new lock class to a spinlock instance.

SpinLock does not manage the interrupt state, so it can be used in only two cases: (a) when the caller knows that interrupts are disabled, or (b) when callers never use it in interrupt handlers (in which case it is ok for interrupts to be enabled).

Implementations

Constructs a new spinlock.

Safety

The caller must call SpinLock::init before using the spinlock.

Locks the spinlock and gives the caller access to the data protected by it. Only one thread at a time is allowed to access the protected data.

Trait Implementations

The type of the data protected by the lock.

Acquires the lock, making the caller its owner.

Releases the lock, giving up ownership of the lock. Read more

Returns the data protected by the lock.

Initialises the type instance so that it can be safely used. Read more

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.