### from_raw Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Creates a new reentrant mutex based on a pre-existing raw mutex and a helper to get the thread ID. ```APIDOC ## pub const fn from_raw(raw_mutex: R, get_thread_id: G, val: T) -> ReentrantMutex ### Description Creates a new reentrant mutex based on a pre-existing raw mutex and a helper to get the thread ID. ``` -------------------------------- ### RwLock::new Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=u32+-%3E+bool Creates a new instance of an RwLock that is initially unlocked. ```APIDOC ## pub const fn new(val: T) -> RwLock ### Description Creates a new instance of an `RwLock` which is unlocked. ``` -------------------------------- ### try_upgradable_read_until Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html Attempts to acquire the RwLock with upgradable read access until a specific instant is reached. ```APIDOC ## fn try_upgradable_read_until(&self, timeout: R::Instant) -> Option> ### Description Attempts to acquire this RwLock with upgradable read access until a timeout is reached. ### Parameters - **timeout** (R::Instant) - The instant until which to wait for the lock. ### Returns - **Option** - Returns the guard if access is granted before the timeout, otherwise None. ``` -------------------------------- ### MappedReentrantMutexGuard::unlock_fair Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search=std%3A%3Avec Unlocks the mutex using a fair unlock protocol to ensure waiting threads get a chance to acquire the lock. ```APIDOC ## pub fn unlock_fair(s: Self) ### Description Unlocks the mutex using a fair unlock protocol. This forces the lock to pass on to a waiting thread if there is one, rather than allowing the current thread to immediately re-lock it. ``` -------------------------------- ### const_new Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html?search= Creates a new reentrant mutex based on a pre-existing raw mutex and a helper to get the thread ID, usable in a constant context. ```APIDOC ## pub const fn const_new(raw_mutex: R, get_thread_id: G, val: T) -> ReentrantMutex ### Description 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. This method is a legacy alias for from_raw. ``` -------------------------------- ### RawReentrantMutex Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RawReentrantMutex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods available for interacting with the RawReentrantMutex. ```APIDOC ## pub fn lock(&self) Acquires this mutex, blocking if it’s held by another thread. ## pub fn try_lock(&self) -> bool Attempts to acquire this mutex without blocking. Returns true if the lock was successfully acquired and false otherwise. ## pub unsafe fn unlock(&self) Unlocks this mutex. This method may only be called if the mutex is held by the current thread. ## pub fn is_locked(&self) -> bool Checks whether the mutex is currently locked. ## pub fn is_owned_by_current_thread(&self) -> bool Checks whether the mutex is currently held by the current thread. ## pub unsafe fn unlock_fair(&self) Unlocks this mutex using a fair unlock protocol. This method may only be called if the mutex is held by the current thread. ## pub unsafe fn bump(&self) Temporarily yields the mutex to a waiting thread if there is one. This method may only be called if the mutex is held by the current thread. ## pub fn try_lock_until(&self, timeout: R::Instant) -> bool Attempts to acquire this lock until a timeout is reached. ## pub fn try_lock_for(&self, timeout: R::Duration) -> bool Attempts to acquire this lock until a timeout is reached. ``` -------------------------------- ### try_upgradable_read Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html Attempts to acquire the RwLock with upgradable read access without blocking. ```APIDOC ## fn try_upgradable_read(&self) -> Option> ### Description Attempts to acquire this RwLock with upgradable read access. This function does not block. ### Returns - **Option** - Returns the guard if access is granted, otherwise None. ``` -------------------------------- ### into_arc_fair Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockReadGuard.html?search=std%3A%3Avec Unlocks the RwLock using a fair protocol and returns the Arc. ```APIDOC ## pub fn into_arc_fair(s: Self) -> Arc> Unlocks the `RwLock` using a fair unlock protocol and returns the `Arc` that was held by the `ArcRwLockReadGuard`. ``` -------------------------------- ### try_upgradable_read_for Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html Attempts to acquire the RwLock with upgradable read access until a timeout duration is reached. ```APIDOC ## fn try_upgradable_read_for(&self, timeout: R::Duration) -> Option> ### Description Attempts to acquire this RwLock with upgradable read access until a timeout is reached. ### Parameters - **timeout** (R::Duration) - The duration to wait for the lock. ### Returns - **Option** - Returns the guard if access is granted before the timeout, otherwise None. ``` -------------------------------- ### new Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Creates a new reentrant mutex in an unlocked state ready for use. ```APIDOC ## pub const fn new(val: T) -> ReentrantMutex ### Description Creates a new reentrant mutex in an unlocked state ready for use. ### Parameters - **val** (T) - The value to be protected by the mutex. ``` -------------------------------- ### RwLockUpgradableReadGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockUpgradableReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods available for managing the state of an upgradable read lock, including upgrades, downgrades, and fair unlocking. ```APIDOC ## Methods ### upgrade(s: Self) -> RwLockWriteGuard Atomically upgrades an upgradable read lock into an exclusive write lock, blocking until acquired. ### try_upgrade(s: Self) -> Result Tries to atomically upgrade to a write lock. Returns the original guard if access is denied. ### downgrade(s: Self) -> RwLockReadGuard Atomically downgrades the upgradable read lock into a shared read lock. ### with_upgraded(&mut self, f: F) -> Ret Upgrades to a write lock, executes the closure with mutable access to the data, and downgrades back to an upgradable read lock. ### try_with_upgraded(&mut self, f: F) -> Option Tries to upgrade to a write lock, executes the closure if successful, and downgrades back. Returns None if upgrade fails. ### unlock_fair(s: Self) Unlocks the lock using a fair protocol to allow waiting threads a chance to acquire the lock. ### bump(s: &mut Self) Yields the lock to a waiting thread if one exists. ``` -------------------------------- ### try_with_upgraded_until Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search= Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified instant timeout is reached. ```APIDOC ## pub fn try_with_upgraded_until Ret>(&mut self, timeout: R::Instant, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a specific instant in time is reached. If the access is granted, the provided closure is executed with an exclusive reference to the data, and the lock is subsequently downgraded back to an upgradable read lock. ### Parameters - **timeout** (R::Instant) - The instant in time until which to wait for the upgrade. - **f** (FnOnce(&mut T) -> Ret) - The closure to execute once the exclusive lock is acquired. ### Returns - **Option** - Returns Some(Ret) if the lock was acquired and the closure executed, otherwise None. ``` -------------------------------- ### try_with_upgraded_until Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified instant timeout is reached. ```APIDOC ## pub fn try_with_upgraded_until Ret>(&mut self, timeout: R::Instant, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a specific instant in time is reached. If the access is granted, it executes the provided closure with an exclusive reference to the data and then downgrades the lock back to an upgradable read lock. ### Parameters - **timeout** (R::Instant) - The instant in time until which to wait for the upgrade. - **f** (F: FnOnce(&mut T) -> Ret) - The closure to execute once the lock is upgraded. ### Returns - **Option** - Returns Some(Ret) if the lock was upgraded and the closure executed, otherwise None. ``` -------------------------------- ### try_with_upgraded_until Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=std%3A%3Avec Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified instant timeout is reached. ```APIDOC ## pub fn try_with_upgraded_until Ret>(&mut self, timeout: R::Instant, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a specific instant in time is reached. If the access is granted, it executes the provided closure with an exclusive reference to the data and then downgrades the lock. ### Parameters - **timeout** (R::Instant) - The instant in time until which to wait for the upgrade. - **f** (F: FnOnce(&mut T) -> Ret) - The closure to execute once the lock is upgraded. ### Returns - **Option** - Returns Some(Ret) if the upgrade was successful and the closure executed, otherwise None. ``` -------------------------------- ### pub fn try_lock_until(&self, timeout: R::Instant) -> Option> Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html?search=u32+-%3E+bool Attempts to acquire the lock until a specific instant in time. Returns an RAII guard if successful, or None if the timeout expires. ```APIDOC ## pub fn try_lock_until(&self, timeout: R::Instant) -> Option> ### Description 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. ``` -------------------------------- ### MappedReentrantMutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedReentrantMutexGuard, returning the original guard and an error if the mapping fails. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. If the closure returns Err, the original guard is returned alongside the error. ``` -------------------------------- ### MappedReentrantMutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html Attempts to create a new MappedReentrantMutexGuard, returning the original guard and an error if the mapping fails. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. If the closure returns an Err, the original guard is returned alongside the error. ``` -------------------------------- ### MappedMutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedMutexGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedMutexGuard, returning the original guard and an error if the mapping fails. ```APIDOC ## MappedMutexGuard::try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedMutexGuard for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns Err. ### Parameters - **s** (Self) - The current MappedMutexGuard instance. - **f** (FnOnce(&mut T) -> Result<&mut U, E>) - A closure that attempts to map the locked data to a subfield. ### Returns - **Result, (Self, E)>** - Returns the new guard on success, or the original guard and error on failure. ``` -------------------------------- ### MappedRwLockReadGuard::try_map_or_else Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockReadGuard.html Attempts to create a new MappedRwLockReadGuard, returning the original guard and an error if the mapping fails. ```APIDOC ## MappedRwLockReadGuard::try_map_or_else ### Description Attempts to make a new MappedRwLockReadGuard for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns Err. ### Signature `pub fn try_map_or_else(s: Self, f: F) -> Result, (Self, E)> where F: FnOnce(&T) -> Result<&U, E>` ``` -------------------------------- ### try_lock_upgradable_until Source: https://docs.rs/lock_api/latest/lock_api/trait.RawRwLockUpgradeTimed.html?search=u32+-%3E+bool Attempts to acquire an upgradable lock until the specified instant timeout is reached. ```APIDOC ## fn try_lock_upgradable_until(&self, timeout: Self::Instant) -> bool ### Description Attempts to acquire an upgradable lock until a timeout is reached. ### Parameters - **timeout** (Self::Instant) - Required - The instant until which to wait for the lock. ### Returns - **bool** - Returns true if the lock was acquired, false otherwise. ``` -------------------------------- ### try_upgrade_until Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specific instant. ```APIDOC ## pub fn try_upgrade_until(s: Self, timeout: R::Instant) -> Result, Self> ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access could not be granted before the timeout expires, then the current guard is returned. ``` -------------------------------- ### RwLockWriteGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockWriteGuard.html?search=std%3A%3Avec Methods available for managing and transforming RwLockWriteGuard instances. ```APIDOC ## pub fn rwlock(s: &Self) -> &'a RwLock Returns a reference to the original reader-writer lock object. ## pub fn map(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U> Creates a new MappedRwLockWriteGuard for a component of the locked data. ## pub fn try_map(s: Self, f: F) -> Result, Self> Attempts to create a new MappedRwLockWriteGuard for a component of the locked data, returning the original guard if the closure returns None. ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> Attempts to create a new MappedRwLockWriteGuard for a component of the locked data, returning the original guard and error if the closure returns Err. ## pub fn unlocked(s: &mut Self, f: F) -> U Temporarily unlocks the RwLock to execute the given function. ## pub fn downgrade(s: Self) -> RwLockReadGuard<'a, R, T> Atomically downgrades a write lock into a read lock. ## pub fn downgrade_to_upgradable(s: Self) -> RwLockUpgradableReadGuard<'a, R, T> Atomically downgrades a write lock into an upgradable read lock. ## pub fn unlock_fair(s: Self) Unlocks the RwLock using a fair unlock protocol. ## pub fn unlocked_fair(s: &mut Self, f: F) -> U Temporarily unlocks the RwLock using a fair unlock protocol to execute the given function. ## pub fn bump(s: &mut Self) Temporarily yields the RwLock to a waiting thread if there is one. ``` -------------------------------- ### try_upgrade_for Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html Tries to atomically upgrade an upgradable read lock into an exclusive write lock within a specified duration. ```APIDOC ## pub fn try_upgrade_for(s: Self, timeout: R::Duration) -> Result, Self> ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access could not be granted before the timeout expires, then the current guard is returned. ``` -------------------------------- ### try_with_upgraded_for Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search= Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified duration timeout is reached. ```APIDOC ## pub fn try_with_upgraded_for Ret>(&mut self, timeout: R::Duration, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access is granted, the provided closure is executed with an exclusive reference to the data, and the lock is subsequently downgraded back to an upgradable read lock. ### Parameters - **timeout** (R::Duration) - The duration to wait for the upgrade. - **f** (FnOnce(&mut T) -> Ret) - The closure to execute once the exclusive lock is acquired. ### Returns - **Option** - Returns Some(Ret) if the lock was acquired and the closure executed, otherwise None. ``` -------------------------------- ### try_with_upgraded_for Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified duration timeout is reached. ```APIDOC ## pub fn try_with_upgraded_for Ret>(&mut self, timeout: R::Duration, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access is granted, it executes the provided closure with an exclusive reference to the data and then downgrades the lock back to an upgradable read lock. ### Parameters - **timeout** (R::Duration) - The duration to wait for the upgrade. - **f** (F: FnOnce(&mut T) -> Ret) - The closure to execute once the lock is upgraded. ### Returns - **Option** - Returns Some(Ret) if the lock was upgraded and the closure executed, otherwise None. ``` -------------------------------- ### try_with_upgraded_for Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=std%3A%3Avec Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specified duration timeout is reached. ```APIDOC ## pub fn try_with_upgraded_for Ret>(&mut self, timeout: R::Duration, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access is granted, it executes the provided closure with an exclusive reference to the data and then downgrades the lock. ### Parameters - **timeout** (R::Duration) - The duration to wait for the upgrade. - **f** (F: FnOnce(&mut T) -> Ret) - The closure to execute once the lock is upgraded. ### Returns - **Option** - Returns Some(Ret) if the upgrade was successful and the closure executed, otherwise None. ``` -------------------------------- ### unlock_fair Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockReadGuard.html?search=std%3A%3Avec Unlocks the RwLock using a fair unlock protocol. ```APIDOC ## pub fn unlock_fair(s: Self) Unlocks the `RwLock` using a fair unlock protocol. ``` -------------------------------- ### pub fn try_lock_for(&self, timeout: R::Duration) -> Option> Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html?search=u32+-%3E+bool Attempts to acquire the lock within a specified duration. Returns an RAII guard if successful, or None if the timeout expires. ```APIDOC ## pub fn try_lock_for(&self, timeout: R::Duration) -> Option> ### Description 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. ``` -------------------------------- ### Try to map a MappedRwLockWriteGuard Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockWriteGuard.html?search= Attempts to create a new guard, returning the original guard if the closure returns None. ```rust pub fn try_map( s: Self, f: F, ) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, ``` -------------------------------- ### RwLockReadGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedRwLockReadGuard for a component of the locked data. ```APIDOC ## pub fn try_map(s: Self, f: F) -> Result, Self> ### Description Attempts to make a new MappedRwLockReadGuard for a component of the locked data. Returns the original guard if the closure returns None. ``` -------------------------------- ### RwLock::try_write Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=u32+-%3E+bool Attempts to acquire exclusive write access without blocking. ```APIDOC ## pub fn try_write(&self) -> Option> ### Description Attempts to lock this `RwLock` with exclusive write access. Returns `None` if the lock cannot be acquired immediately. ``` -------------------------------- ### pub fn bump(s: &mut Self) Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcMutexGuard.html Temporarily yields the mutex to a waiting thread if there is one. ```APIDOC ## pub fn bump(s: &mut Self) ### Description Temporarily yields the mutex to a waiting thread if there is one. This is functionally identical to the bump method on MutexGuard. ``` -------------------------------- ### MappedRwLockWriteGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockWriteGuard.html Attempts to create a new MappedRwLockWriteGuard, returning the original guard and an error if the closure fails. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to map the guard to a subfield. If the closure returns an error, the original guard and the error are returned. ### Parameters - **s** (Self) - The original guard. - **f** (FnOnce(&mut T) -> Result<&mut U, E>) - A closure that attempts to map the locked data to a subfield. ``` -------------------------------- ### try_write_until Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to acquire write access until a specific instant is reached. ```APIDOC ## pub fn try_write_until(&self, timeout: R::Instant) -> Option> ### Description Attempts to acquire this RwLock with exclusive write access until a timeout is reached. If the access could not be granted before the timeout expires, None is returned. ``` -------------------------------- ### RwLockReadGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedRwLockReadGuard, returning the original guard and an error if the closure fails. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedRwLockReadGuard for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns Err. ``` -------------------------------- ### Mutex Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.Mutex.html?search=u32+-%3E+bool Methods available for the Mutex synchronization primitive. ```APIDOC ## pub fn new(val: T) -> Mutex Creates a new mutex in an unlocked state. ## pub fn into_inner(self) -> T Consumes the mutex and returns the underlying data. ## pub fn lock(&self) -> MutexGuard<'_, R, T> Acquires the mutex, blocking the current thread until available. ## pub fn try_lock(&self) -> Option> Attempts to acquire the lock without blocking. Returns None if the lock is held. ## pub fn is_locked(&self) -> bool Checks if the mutex is currently locked. ## pub fn get_mut(&mut self) -> &mut T Returns a mutable reference to the underlying data, requiring a mutable borrow of the mutex. ``` -------------------------------- ### MappedReentrantMutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search=std%3A%3Avec Attempts to create a new MappedReentrantMutexGuard, returning the original guard and an error if the closure returns an Err. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns Err. ``` -------------------------------- ### RwLockWriteGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockWriteGuard.html?search=u32+-%3E+bool Methods available on the RwLockWriteGuard structure for lock management. ```APIDOC ## RwLockWriteGuard::rwlock Returns a reference to the original reader-writer lock object. ## RwLockWriteGuard::map Creates a new MappedRwLockWriteGuard for a component of the locked data using a closure. ## RwLockWriteGuard::try_map Attempts to create a new MappedRwLockWriteGuard for a component of the locked data, returning the original guard if the closure returns None. ## RwLockWriteGuard::try_map_or_err Attempts to create a new MappedRwLockWriteGuard for a component of the locked data, returning the original guard and an error if the closure returns Err. ## RwLockWriteGuard::unlocked Temporarily unlocks the RwLock to execute a provided function. ## RwLockWriteGuard::downgrade Atomically downgrades a write lock into a read lock. ## RwLockWriteGuard::downgrade_to_upgradable Atomically downgrades a write lock into an upgradable read lock. ## RwLockWriteGuard::unlock_fair Unlocks the RwLock using a fair unlock protocol to allow waiting threads a chance to acquire the lock. ## RwLockWriteGuard::unlocked_fair Temporarily unlocks the RwLock using a fair protocol to execute a provided function. ## RwLockWriteGuard::bump Temporarily yields the RwLock to a waiting thread if one exists. ``` -------------------------------- ### try_with_upgraded_until Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=u32+-%3E+bool Tries to atomically upgrade an upgradable read lock into an exclusive write lock until a specific instant in time. If successful, executes a closure with the exclusive reference and downgrades the lock afterwards. ```APIDOC ## pub fn try_with_upgraded_until Ret>(&mut self, timeout: R::Instant, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access could not be granted before the timeout expires, then None is returned. Otherwise, calls the provided closure with an exclusive reference to the lock’s data, and finally downgrades the lock back to an upgradable read lock. ``` -------------------------------- ### MappedReentrantMutexGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedReentrantMutexGuard for a component of the locked data, returning the original guard if the mapping fails. ```APIDOC ## pub fn try_map(s: Self, f: F) -> Result, Self> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. If the closure returns None, the original guard is returned. ### Parameters - **s** (Self) - The current MappedReentrantMutexGuard. - **f** (F) - A closure that maps the reference of the current data to an Option containing a reference of the component. ``` -------------------------------- ### MappedReentrantMutexGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html Attempts to create a new MappedReentrantMutexGuard for a component of the locked data, returning the original guard if the mapping fails. ```APIDOC ## pub fn try_map(s: Self, f: F) -> Result, Self> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. If the closure returns None, the original guard is returned. ### Parameters - **s** (Self) - The current guard instance. - **f** (F) - A closure that attempts to map the reference of the current data to an Option containing a reference to the subfield. ``` -------------------------------- ### pub fn try_lock_arc_until(self: &Arc, timeout: R::Instant) -> Option> Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html?search=u32+-%3E+bool Attempts to acquire the lock until a specific instant for an Arc-wrapped ReentrantMutex. Requires the 'arc_lock' feature. ```APIDOC ## pub fn try_lock_arc_until(self: &Arc, timeout: R::Instant) -> Option> ### Description Attempts to acquire this lock until a timeout is reached, through an `Arc`. This method requires the `ReentrantMutex` to be inside of an `Arc` and the resulting mutex guard has no lifetime requirements. Available on crate feature `arc_lock` only. ``` -------------------------------- ### MutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MutexGuard.html Attempts to create a new MappedMutexGuard, returning the original guard and user data if the closure returns Err. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new `MappedMutexGuard` for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns `Err`. ``` -------------------------------- ### Create ReentrantMutex from raw components Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Initializes a reentrant mutex using a raw mutex and a thread ID provider. ```rust pub const fn from_raw( raw_mutex: R, get_thread_id: G, val: T, ) -> ReentrantMutex ``` ```rust pub const fn const_new( raw_mutex: R, get_thread_id: G, val: T, ) -> ReentrantMutex ``` -------------------------------- ### RwLock::try_read Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=u32+-%3E+bool Attempts to acquire shared read access without blocking. ```APIDOC ## pub fn try_read(&self) -> Option> ### Description Attempts to acquire this `RwLock` with shared read access. Returns `None` if the lock cannot be acquired immediately. ``` -------------------------------- ### into_inner Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Consumes the mutex and returns the underlying data. ```APIDOC ## pub fn into_inner(self) -> T ### Description Consumes this mutex, returning the underlying data. ``` -------------------------------- ### RwLockWriteGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockWriteGuard.html?search=u32+-%3E+bool Methods for accessing the underlying lock, mapping data, and temporary unlocking. ```rust pub fn rwlock(s: &Self) -> &'a RwLock ``` ```rust pub fn map(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U> where F: FnOnce(&mut T) -> &mut U, ``` ```rust pub fn try_map( s: Self, f: F, ) -> Result, Self> where F: FnOnce(&mut T) -> Option<&mut U>, ``` ```rust pub fn try_map_or_err( s: Self, f: F, ) -> Result, (Self, E)> where F: FnOnce(&mut T) -> Result<&mut U, E>, ``` ```rust pub fn unlocked(s: &mut Self, f: F) -> U where F: FnOnce() -> U, ``` -------------------------------- ### Try Map MappedMutexGuard with Error Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedMutexGuard.html?search= Attempts to map to a subfield, returning the original guard and an error if the closure returns Err. ```rust pub fn try_map_or_err( s: Self, f: F, ) -> Result, (Self, E)> where F: FnOnce(&mut T) -> Result<&mut U, E>, ``` -------------------------------- ### Create and Consume ReentrantMutex Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html?search= Methods for initializing a new ReentrantMutex and consuming it to retrieve the inner data. ```rust pub const fn new(val: T) -> ReentrantMutex ``` ```rust pub fn into_inner(self) -> T ``` -------------------------------- ### const_new Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Creates a new reentrant mutex in a constant context. ```APIDOC ## pub const fn const_new(raw_mutex: R, get_thread_id: G, val: T) -> ReentrantMutex ### Description 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. ``` -------------------------------- ### MappedMutexGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedMutexGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedMutexGuard for a component of the locked data, returning the original guard if the mapping fails. ```APIDOC ## MappedMutexGuard::try_map(s: Self, f: F) -> Result, Self> ### Description Attempts to make a new MappedMutexGuard for a component of the locked data. The original guard is returned if the closure returns None. ### Parameters - **s** (Self) - The current MappedMutexGuard instance. - **f** (FnOnce(&mut T) -> Option<&mut U>) - A closure that attempts to map the locked data to a subfield. ### Returns - **Result, Self>** - Returns the new guard on success, or the original guard on failure. ``` -------------------------------- ### try_with_upgraded_for Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcRwLockUpgradableReadGuard.html?search=u32+-%3E+bool Tries to atomically upgrade an upgradable read lock into an exclusive write lock within a specified duration. If successful, executes a closure with the exclusive reference and downgrades the lock afterwards. ```APIDOC ## pub fn try_with_upgraded_for Ret>(&mut self, timeout: R::Duration, f: F) -> Option ### Description Tries to atomically upgrade an upgradable read lock into an exclusive write lock, until a timeout is reached. If the access could not be granted before the timeout expires, then None is returned. Otherwise, calls the provided closure with an exclusive reference to the lock’s data, and finally downgrades the lock back to an upgradable read lock. ``` -------------------------------- ### unsafe fn unlock_upgradable_fair(&self) Source: https://docs.rs/lock_api/latest/lock_api/trait.RawRwLockUpgradeFair.html Releases an upgradable lock using a fair unlock protocol. This method is unsafe and must only be called if an upgradable lock is held in the current context. ```APIDOC ## unsafe fn unlock_upgradable_fair(&self) ### Description Releases an upgradable lock using a fair unlock protocol. ### Safety This method may only be called if an upgradable lock is held in the current context. ``` -------------------------------- ### try_write_for Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to acquire write access until a timeout duration is reached. ```APIDOC ## pub fn try_write_for(&self, timeout: R::Duration) -> Option> ### Description Attempts to acquire this RwLock with exclusive write access until a timeout is reached. If the access could not be granted before the timeout expires, None is returned. ``` -------------------------------- ### unsafe fn bump_upgradable(&self) Source: https://docs.rs/lock_api/latest/lock_api/trait.RawRwLockUpgradeFair.html?search=std%3A%3Avec Temporarily yields an upgradable lock to a waiting thread if one exists. This is more efficient than a full unlock and re-lock cycle when no threads are waiting. ```APIDOC ### unsafe fn bump_upgradable(&self) #### Description Temporarily yields an upgradable lock to a waiting thread if there is one. This method is functionally equivalent to calling `unlock_upgradable_fair` followed by `lock_upgradable`. #### Safety This method may only be called if an upgradable lock is held in the current context. ``` -------------------------------- ### Create a new ReentrantMutex Source: https://docs.rs/lock_api/latest/lock_api/struct.ReentrantMutex.html Initializes a new reentrant mutex in an unlocked state. ```rust pub const fn new(val: T) -> ReentrantMutex ``` -------------------------------- ### ArcReentrantMutexGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcReentrantMutexGuard.html?search= Methods for interacting with the guard, including retrieving the Arc, unlocking, and temporary unlocking. ```rust pub fn remutex(s: &Self) -> &Arc> ``` ```rust pub fn into_arc(s: Self) -> Arc> ``` ```rust pub fn unlocked(s: &mut Self, f: F) -> U where F: FnOnce() -> U, ``` -------------------------------- ### RwLockReadGuard Methods Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockReadGuard.html?search= Methods for accessing the underlying lock, mapping data, and managing temporary unlocking. ```rust pub fn rwlock(s: &Self) -> &'a RwLock ``` ```rust pub fn map(s: Self, f: F) -> MappedRwLockReadGuard<'a, R, U> where F: FnOnce(&T) -> &U, ``` ```rust pub fn try_map( s: Self, f: F, ) -> Result, Self> where F: FnOnce(&T) -> Option<&U>, ``` ```rust pub fn try_map_or_err( s: Self, f: F, ) -> Result, (Self, E)> where F: FnOnce(&T) -> Result<&U, E>, ``` ```rust pub fn unlocked(s: &mut Self, f: F) -> U where F: FnOnce() -> U, ``` -------------------------------- ### pub fn mutex(s: &Self) -> &Arc> Source: https://docs.rs/lock_api/latest/lock_api/struct.ArcMutexGuard.html Returns a reference to the Mutex this is guarding, contained in its Arc. ```APIDOC ## pub fn mutex(s: &Self) -> &Arc> ### Description Returns a reference to the Mutex this is guarding, contained in its Arc. ``` -------------------------------- ### upgradable_read Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html Locks the RwLock with upgradable read access, blocking until acquired. ```APIDOC ## fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T> ### Description Locks this RwLock with upgradable read access, blocking the current thread until it can be acquired. The calling thread will be blocked until there are no more writers or other upgradable reads which hold the lock. ### Returns - **RwLockUpgradableReadGuard** - An RAII guard which will release this thread’s shared access once it is dropped. ``` -------------------------------- ### MappedRwLockReadGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockReadGuard.html Attempts to create a new MappedRwLockReadGuard for a component of the locked data, returning the original guard if the mapping fails. ```APIDOC ## MappedRwLockReadGuard::try_map ### Description Attempts to make a new MappedRwLockReadGuard for a component of the locked data. The original guard is returned if the closure returns None. ### Signature `pub fn try_map(s: Self, f: F) -> Result, Self> where F: FnOnce(&T) -> Option<&U>` ``` -------------------------------- ### MappedRwLockReadGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockReadGuard.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to create a new MappedRwLockReadGuard for a component of the locked data, returning the original guard if the mapping fails. ```APIDOC ## MappedRwLockReadGuard::try_map ### Description Attempts to map the guard to a subfield. If the provided closure returns `None`, the original guard is returned. ### Signature `pub fn try_map(s: Self, f: F) -> Result, Self> where F: FnOnce(&T) -> Option<&U>` ``` -------------------------------- ### try_read_until Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Attempts to acquire read access until a specific instant is reached. ```APIDOC ## pub fn try_read_until(&self, timeout: R::Instant) -> Option> ### Description Attempts to acquire this RwLock with shared read access until a timeout is reached. If the access could not be granted before the timeout expires, None is returned. ``` -------------------------------- ### Fair MutexGuard methods Source: https://docs.rs/lock_api/latest/lock_api/struct.MutexGuard.html?search= Methods for fair locking protocols available when the underlying mutex supports RawMutexFair. ```rust pub fn unlock_fair(s: Self) ``` ```rust pub fn unlocked_fair(s: &mut Self, f: F) -> U where F: FnOnce() -> U, ``` ```rust pub fn bump(s: &mut Self) ``` -------------------------------- ### try_lock_upgradable_for Source: https://docs.rs/lock_api/latest/lock_api/trait.RawRwLockUpgradeTimed.html?search=u32+-%3E+bool Attempts to acquire an upgradable lock until the specified duration timeout is reached. ```APIDOC ## fn try_lock_upgradable_for(&self, timeout: Self::Duration) -> bool ### Description Attempts to acquire an upgradable lock until a timeout is reached. ### Parameters - **timeout** (Self::Duration) - Required - The duration to wait for the lock. ### Returns - **bool** - Returns true if the lock was acquired, false otherwise. ``` -------------------------------- ### MappedRwLockWriteGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockWriteGuard.html?search=std%3A%3Avec Attempts to map the locked data, returning the original guard and an error if the mapping fails. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to map the locked data to a subfield. If the closure returns `Err`, the original guard and the error are returned. ### Parameters - **s** (Self) - The current guard instance. - **f** (FnOnce(&mut T) -> Result<&mut U, E>) - A closure that attempts to map the locked data. ### Returns - **Result, (Self, E)>** - The new guard on success, or a tuple of the original guard and error on failure. ``` -------------------------------- ### MappedRwLockWriteGuard::try_map Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedRwLockWriteGuard.html Attempts to create a new MappedRwLockWriteGuard for a component of the locked data, returning the original guard if the closure returns None. ```APIDOC ## pub fn try_map(s: Self, f: F) -> Result, Self> ### Description Attempts to map the guard to a subfield. If the closure returns None, the original guard is returned. ### Parameters - **s** (Self) - The original guard. - **f** (FnOnce(&mut T) -> Option<&mut U>) - A closure that attempts to map the locked data to a subfield. ``` -------------------------------- ### RwLockWriteGuard Structure Definition Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLockWriteGuard.html?search= The base structure definition for the write guard. ```rust pub struct RwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> { /* private fields */ } ``` -------------------------------- ### try_write_until Source: https://docs.rs/lock_api/latest/lock_api/struct.RwLock.html?search=std%3A%3Avec Attempts to acquire exclusive write access until a specified instant is reached. ```APIDOC ## pub fn try_write_until(&self, timeout: R::Instant) -> Option> ### Description Attempts to acquire this RwLock with exclusive write access until a timeout is reached. If the access could not be granted before the timeout expires, then None is returned. ``` -------------------------------- ### Attempt to map with error handling Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search=std%3A%3Avec Attempts to create a new guard, returning the original guard and an error if the closure returns Err. ```rust pub fn try_map_or_err( s: Self, f: F, ) -> Result, (Self, E)> where F: FnOnce(&T) -> Result<&U, E>, ``` -------------------------------- ### MappedReentrantMutexGuard::try_map_or_err Source: https://docs.rs/lock_api/latest/lock_api/struct.MappedReentrantMutexGuard.html?search= Attempts to create a new MappedReentrantMutexGuard for a component of the locked data, returning the original guard and an error if the closure returns Err. ```APIDOC ## pub fn try_map_or_err(s: Self, f: F) -> Result, (Self, E)> ### Description Attempts to make a new MappedReentrantMutexGuard for a component of the locked data. The original guard is returned alongside arbitrary user data if the closure returns Err. ### Parameters - **s** (Self) - The current guard. - **f** (FnOnce(&T) -> Result<&U, E>) - A closure that attempts to map the reference of the locked data to a sub-component. ```