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

pub struct ReentrantMutex<R, G, T> where
    T: ?Sized
{ /* fields omitted */ }
Expand description

A mutex which can be recursively locked by a single thread.

This type is identical to Mutex except for the following points:

  • Locking multiple times from the same thread will work correctly instead of deadlocking.
  • ReentrantMutexGuard does not give mutable references to the locked data. Use a RefCell if you need this.

See Mutex for more details about the underlying mutex primitive.

Implementations

Creates a new reentrant mutex in an unlocked state ready for use.

Consumes this mutex, returning the underlying data.

Creates a new reentrant mutex based on a pre-existing raw mutex and a helper to get the thread ID.

This allows creating a reentrant mutex in a constant context on stable Rust.

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

If the mutex is held by another thread then this function will block the local thread until it is available to acquire the mutex. If the mutex is already held by the current thread then this function will increment the lock reference count and return immediately. Upon returning, the thread is the only thread with the mutex held. An RAII guard is returned to allow scoped unlock of the lock. When the guard goes out of scope, the mutex will be unlocked.

Attempts to acquire this lock.

If the lock could not be acquired at this time, then None is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

This function does not block.

Returns a mutable reference to the underlying data.

Since this call borrows the ReentrantMutex mutably, no actual locking needs to take place—the mutable borrow statically guarantees no locks exist.

Checks whether the mutex is currently locked.

Checks whether the mutex is currently held by the current thread.

Forcibly unlocks the mutex.

This is useful when combined with mem::forget to hold a lock without the need to maintain a ReentrantMutexGuard object alive, for example when dealing with FFI.

Safety

This method must only be called if the current thread logically owns a ReentrantMutexGuard but that guard has be discarded using mem::forget. Behavior is undefined if a mutex is unlocked when not locked.

Returns the underlying raw mutex object.

Note that you will most likely need to import the RawMutex trait from lock_api to be able to call functions on the raw mutex.

Safety

This method is unsafe because it allows unlocking a mutex while still holding a reference to a ReentrantMutexGuard.

Returns a raw pointer to the underlying data.

This is useful when combined with mem::forget to hold a lock without the need to maintain a ReentrantMutexGuard object alive, for example when dealing with FFI.

Safety

You must ensure that there are no data races when dereferencing the returned pointer, for example if the current thread logically owns a ReentrantMutexGuard but that guard has been discarded using mem::forget.

Forcibly unlocks the mutex using a fair unlock protocol.

This is useful when combined with mem::forget to hold a lock without the need to maintain a ReentrantMutexGuard object alive, for example when dealing with FFI.

Safety

This method must only be called if the current thread logically owns a ReentrantMutexGuard but that guard has be discarded using mem::forget. Behavior is undefined if a mutex is unlocked when not locked.

Attempts to acquire this lock until a timeout is reached.

If the lock could not be acquired before the timeout expired, then None is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

Attempts to acquire this lock until a timeout is reached.

If the lock could not be acquired before the timeout expired, then None is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

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.

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

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.