Struct otter_api_tests::imports::parking_lot::lock_api::MutexGuard[]

#[must_use = "if unused the Mutex will immediately unlock"]
pub struct MutexGuard<'a, R, T> where
    T: ?Sized,
    R: RawMutex
{ /* fields omitted */ }
Expand description

An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.

The data protected by the mutex can be accessed through this guard via its Deref and DerefMut implementations.

Implementations

Returns a reference to the original Mutex object.

Makes a new MappedMutexGuard for a component of the locked data.

This operation cannot fail as the MutexGuard passed in already locked the mutex.

This is an associated function that needs to be used as MutexGuard::map(...). A method would interfere with methods of the same name on the contents of the locked data.

Attempts to make a new MappedMutexGuard for a component of the locked data. The original guard is returned if the closure returns None.

This operation cannot fail as the MutexGuard passed in already locked the mutex.

This is an associated function that needs to be used as MutexGuard::try_map(...). A method would interfere with methods of the same name on the contents of the locked data.

Temporarily unlocks the mutex to execute the given function.

This is safe because &mut guarantees that there exist no other references to the data protected by the mutex.

Unlocks the mutex using a fair unlock protocol.

By default, mutexes are unfair and allow the current thread to re-lock the mutex before another has the chance to acquire the lock, even if that thread has been blocked on the mutex for a long time. This is the default because it allows much higher throughput as it avoids forcing a context switch on every mutex unlock. This can result in one thread acquiring a mutex many more times than other threads.

However in some cases it can be beneficial to ensure fairness by forcing the lock to pass on to a waiting thread if there is one. This is done by using this method instead of dropping the MutexGuard normally.

Temporarily unlocks the mutex to execute the given function.

The mutex is unlocked using a fair unlock protocol.

This is safe because &mut guarantees that there exist no other references to the data protected by the mutex.

Temporarily yields the mutex to a waiting thread if there is one.

This method is functionally equivalent to calling unlock_fair followed by lock, however it can be much more efficient in the case where there are no waiting threads.

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Executes the destructor for this type. 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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Use this to cast from one trait object type to another. Read more

Use this to upcast a trait to one of its supertraits. Read more

Use this to cast from one trait object type to another. This method is more customizable than the dyn_cast method. Here you can also specify the “source” trait from which the cast is defined. This can for example allow using casts from a supertrait of the current trait object. Read more

Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

Converts the given value to a String. 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.