pub struct RwSemaphore<T: ?Sized> { /* private fields */ }
Expand description

Exposes the kernel’s struct rw_semaphore.

It’s a read/write mutex. That is, it allows multiple readers to acquire it concurrently, but only one writer at a time. On contention, waiters sleep.

A RwSemaphore must first be initialised with a call to RwSemaphore::init_lock before it can be used. The rwsemaphore_init macro is provided to automatically assign a new lock class to an RwSemaphore instance.

Since it may block, RwSemaphore needs to be used with care in atomic contexts.

Implementations

Constructs a new rw semaphore.

Safety

The caller must call RwSemaphore::init_lock before using the rw semaphore.

Locks the rw semaphore in write (exclusive) mode and gives the caller access to the data protected by it. Only one thread at a time is allowed to access the protected data.

Locks the rw semaphore in read (shared) mode 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.
The type of context, if any, that needs to be stored in the guard.
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.
Reacquires the lock, making the caller its owner. Read more
The type of the data protected by the lock.
The type of context, if any, that needs to be stored in the guard.
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.
Reacquires the lock, making the caller its owner. Read more
The parametrised type of the mutual exclusion primitive that can be created by this factory.
Constructs a new instance of the mutual exclusion primitive. Read more
Initialises the lock instance so that it can be safely used.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Initialises the type instance so that it can be safely used. Read more
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.