pub type ReentrantMutex<T> = ReentrantMutex<RawMutex, RawThreadId, T>;Expand description
A reentrant mutual exclusion lock.
This lock blocks other threads waiting for it to become available. A thread which already holds the lock can acquire it additional times without blocking.
Unlike Mutex, ReentrantMutexGuard does not provide
mutable references to the locked data, because multiple guards can coexist
on the same thread. Use interior mutability, such as RefCell,
to mutate the guarded data.
See Mutex for more details about the underlying mutex
primitive.
§Examples
use parking_lot::ReentrantMutex;
use std::cell::RefCell;
let lock = ReentrantMutex::new(RefCell::new(0));
let first = lock.lock();
let second = lock.lock();
*first.borrow_mut() += 1;
*second.borrow_mut() += 1;
assert_eq!(*lock.lock().borrow(), 2);Aliased Type§
pub struct ReentrantMutex<T> { /* private fields */ }