pub struct RocketMQTokioRwLock<T: ?Sized> { /* private fields */ }
Implementations§
Source§impl<T: ?Sized> RocketMQTokioRwLock<T>
impl<T: ?Sized> RocketMQTokioRwLock<T>
Sourcepub fn new_rw_lock(lock: RwLock<T>) -> Selfwhere
T: Sized,
pub fn new_rw_lock(lock: RwLock<T>) -> Selfwhere
T: Sized,
Sourcepub async fn read(&self) -> RwLockReadGuard<'_, T>
pub async fn read(&self) -> RwLockReadGuard<'_, T>
Acquires a read lock asynchronously, blocking the current task until it is able to do so.
§Returns
A RwLockReadGuard
that releases the read lock when dropped.
Sourcepub async fn write(&self) -> RwLockWriteGuard<'_, T>
pub async fn write(&self) -> RwLockWriteGuard<'_, T>
Acquires a write lock asynchronously, blocking the current task until it is able to do so.
§Returns
A RwLockWriteGuard
that releases the write lock when dropped.
Sourcepub async fn try_read(&self) -> Option<RwLockReadGuard<'_, T>>
pub async fn try_read(&self) -> Option<RwLockReadGuard<'_, T>>
Attempts to acquire a read lock asynchronously without blocking.
§Returns
An Option
containing a RwLockReadGuard
if the read lock was successfully acquired, or
None
if the lock is already held.
Sourcepub async fn try_write(&self) -> Option<RwLockWriteGuard<'_, T>>
pub async fn try_write(&self) -> Option<RwLockWriteGuard<'_, T>>
Attempts to acquire a write lock asynchronously without blocking.
§Returns
An Option
containing a RwLockWriteGuard
if the write lock was successfully acquired, or
None
if the lock is already held.
Sourcepub async fn try_read_timeout(
&self,
timeout: Duration,
) -> Option<RwLockReadGuard<'_, T>>
pub async fn try_read_timeout( &self, timeout: Duration, ) -> Option<RwLockReadGuard<'_, T>>
Attempts to acquire a read lock asynchronously, blocking for up to the specified timeout.
§Arguments
timeout
- The maximum duration to wait for the read lock.
§Returns
An Option
containing a RwLockReadGuard
if the read lock was successfully acquired within
the timeout, or None
if the timeout expired.
Sourcepub async fn try_write_timeout(
&self,
timeout: Duration,
) -> Option<RwLockWriteGuard<'_, T>>
pub async fn try_write_timeout( &self, timeout: Duration, ) -> Option<RwLockWriteGuard<'_, T>>
Attempts to acquire a write lock asynchronously, blocking for up to the specified timeout.
§Arguments
timeout
- The maximum duration to wait for the write lock.
§Returns
An Option
containing a RwLockWriteGuard
if the write lock was successfully acquired
within the timeout, or None
if the timeout expired.