Struct RwLock
pub struct RwLock<R, T>where
T: ?Sized,{
raw: R,
data: UnsafeCell<T>,
}
Expand description
A reader-writer lock
This type of lock allows a number of readers or at most one writer at any point in time. The write portion of this lock typically allows modification of the underlying data (exclusive access) and the read portion of this lock typically allows for read-only access (shared access).
The type parameter T
represents the data that this lock protects. It is
required that T
satisfies Send
to be shared across threads and Sync
to
allow concurrent access through readers. The RAII guards returned from the
locking methods implement Deref
(and DerefMut
for the write
methods)
to allow access to the contained of the lock.
Fields§
§raw: R
§data: UnsafeCell<T>
Implementations§
§impl<R, T> RwLock<R, T>where
R: RawRwLock,
impl<R, T> RwLock<R, T>where
R: RawRwLock,
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this RwLock
, returning the underlying data.
§impl<R, T> RwLock<R, T>
impl<R, T> RwLock<R, T>
§impl<R, T> RwLock<R, T>
impl<R, T> RwLock<R, T>
pub unsafe fn make_read_guard_unchecked(&self) -> RwLockReadGuard<'_, R, T>
pub unsafe fn make_read_guard_unchecked(&self) -> RwLockReadGuard<'_, R, T>
Creates a new RwLockReadGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget
.
pub unsafe fn make_write_guard_unchecked(&self) -> RwLockWriteGuard<'_, R, T>
pub unsafe fn make_write_guard_unchecked(&self) -> RwLockWriteGuard<'_, R, T>
Creates a new RwLockReadGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a write lock.
Calling this function when a guard has already been produced is undefined behaviour unless
the guard was forgotten with mem::forget
.
pub fn read(&self) -> RwLockReadGuard<'_, R, T>
pub fn read(&self) -> RwLockReadGuard<'_, R, T>
Locks this RwLock
with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns.
Note that attempts to recursively acquire a read lock on a RwLock
when
the current thread already holds one may result in a deadlock.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock
with shared read access.
If the access could not be granted at this time, then None
is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This function does not block.
pub fn write(&self) -> RwLockWriteGuard<'_, R, T>
pub fn write(&self) -> RwLockWriteGuard<'_, R, T>
Locks this RwLock
with exclusive write access, blocking the current
thread until it can be acquired.
This function will not return while other writers or other readers currently have access to the lock.
Returns an RAII guard which will drop the write access of this RwLock
when dropped.
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, R, T>>
Attempts to lock this RwLock
with exclusive write access.
If the lock could not be acquired at this time, then None
is returned.
Otherwise, an RAII guard is returned which will release the lock when
it is dropped.
This function does not block.
pub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
Since this call borrows the RwLock
mutably, no actual locking needs to
take place—the mutable borrow statically guarantees no locks exist.
pub fn is_locked_exclusive(&self) -> bool
pub fn is_locked_exclusive(&self) -> bool
Check if this RwLock
is currently exclusively locked.
pub unsafe fn force_unlock_read(&self)
pub unsafe fn force_unlock_read(&self)
Forcibly unlocks a read lock.
This is useful when combined with mem::forget
to hold a lock without
the need to maintain a RwLockReadGuard
object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockReadGuard
but that guard has be discarded using mem::forget
.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
pub unsafe fn force_unlock_write(&self)
pub unsafe fn force_unlock_write(&self)
Forcibly unlocks a write lock.
This is useful when combined with mem::forget
to hold a lock without
the need to maintain a RwLockWriteGuard
object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockWriteGuard
but that guard has be discarded using mem::forget
.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
pub unsafe fn raw(&self) -> &R
pub unsafe fn raw(&self) -> &R
Returns the underlying raw reader-writer lock object.
Note that you will most likely need to import the RawRwLock
trait from
lock_api
to be able to call functions on the raw
reader-writer lock.
§Safety
This method is unsafe because it allows unlocking a mutex while still holding a reference to a lock guard.
pub fn data_ptr(&self) -> *mut T
pub fn data_ptr(&self) -> *mut T
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 RwLockReadGuard
or RwLockWriteGuard
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
RwLockReadGuard
or RwLockWriteGuard
but that guard has been discarded
using mem::forget
.
pub unsafe fn make_arc_read_guard_unchecked(
self: &Arc<RwLock<R, T>>,
) -> ArcRwLockReadGuard<R, T>
pub unsafe fn make_arc_read_guard_unchecked( self: &Arc<RwLock<R, T>>, ) -> ArcRwLockReadGuard<R, T>
Creates a new RwLockReadGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget
.`
pub unsafe fn make_arc_write_guard_unchecked(
self: &Arc<RwLock<R, T>>,
) -> ArcRwLockWriteGuard<R, T>
pub unsafe fn make_arc_write_guard_unchecked( self: &Arc<RwLock<R, T>>, ) -> ArcRwLockWriteGuard<R, T>
Creates a new RwLockWriteGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds a write lock.
Calling this function when a guard has already been produced is undefined behaviour unless
the guard was forgotten with mem::forget
.
pub fn read_arc(self: &Arc<RwLock<R, T>>) -> ArcRwLockReadGuard<R, T>
pub fn read_arc(self: &Arc<RwLock<R, T>>) -> ArcRwLockReadGuard<R, T>
Locks this RwLock
with read access, through an Arc
.
This method is similar to the read
method; however, it requires the RwLock
to be inside of an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_read_arc(
self: &Arc<RwLock<R, T>>,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_arc( self: &Arc<RwLock<R, T>>, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to lock this RwLock
with read access, through an Arc
.
This method is similar to the try_read
method; however, it requires the RwLock
to be inside of an
Arc
and the resulting read guard has no lifetime requirements.
pub fn write_arc(self: &Arc<RwLock<R, T>>) -> ArcRwLockWriteGuard<R, T>
pub fn write_arc(self: &Arc<RwLock<R, T>>) -> ArcRwLockWriteGuard<R, T>
Locks this RwLock
with write access, through an Arc
.
This method is similar to the write
method; however, it requires the RwLock
to be inside of an Arc
and the resulting write guard has no lifetime requirements.
pub fn try_write_arc(
self: &Arc<RwLock<R, T>>,
) -> Option<ArcRwLockWriteGuard<R, T>>
pub fn try_write_arc( self: &Arc<RwLock<R, T>>, ) -> Option<ArcRwLockWriteGuard<R, T>>
Attempts to lock this RwLock
with writ access, through an Arc
.
This method is similar to the try_write
method; however, it requires the RwLock
to be inside of an
Arc
and the resulting write guard has no lifetime requirements.
§impl<R, T> RwLock<R, T>where
R: RawRwLockFair,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockFair,
T: ?Sized,
pub unsafe fn force_unlock_read_fair(&self)
pub unsafe fn force_unlock_read_fair(&self)
Forcibly unlocks a read lock using a fair unlock protocol.
This is useful when combined with mem::forget
to hold a lock without
the need to maintain a RwLockReadGuard
object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockReadGuard
but that guard has be discarded using mem::forget
.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
pub unsafe fn force_unlock_write_fair(&self)
pub unsafe fn force_unlock_write_fair(&self)
Forcibly unlocks a write lock using a fair unlock protocol.
This is useful when combined with mem::forget
to hold a lock without
the need to maintain a RwLockWriteGuard
object alive, for example when
dealing with FFI.
§Safety
This method must only be called if the current thread logically owns a
RwLockWriteGuard
but that guard has be discarded using mem::forget
.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
§impl<R, T> RwLock<R, T>where
R: RawRwLockTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockTimed,
T: ?Sized,
pub fn try_read_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockReadGuard<'_, R, T>>
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, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
pub fn try_read_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockReadGuard<'_, R, T>>
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, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
pub fn try_write_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockWriteGuard<'_, R, T>>
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. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
pub fn try_write_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockWriteGuard<'_, R, T>>
pub fn try_write_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockWriteGuard<'_, R, T>>
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. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
pub fn try_read_arc_for(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_arc_for( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to acquire this RwLock
with read access until a timeout is reached, through an Arc
.
This method is similar to the try_read_for
method; however, it requires the RwLock
to be inside of an
Arc
and the resulting read guard has no lifetime requirements.
pub fn try_read_arc_until(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_arc_until( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to acquire this RwLock
with read access until a timeout is reached, through an Arc
.
This method is similar to the try_read_until
method; however, it requires the RwLock
to be inside of
an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_write_arc_for(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<ArcRwLockWriteGuard<R, T>>
pub fn try_write_arc_for( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<ArcRwLockWriteGuard<R, T>>
Attempts to acquire this RwLock
with write access until a timeout is reached, through an Arc
.
This method is similar to the try_write_for
method; however, it requires the RwLock
to be inside of
an Arc
and the resulting write guard has no lifetime requirements.
pub fn try_write_arc_until(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<ArcRwLockWriteGuard<R, T>>
pub fn try_write_arc_until( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<ArcRwLockWriteGuard<R, T>>
Attempts to acquire this RwLock
with read access until a timeout is reached, through an Arc
.
This method is similar to the try_write_until
method; however, it requires the RwLock
to be inside of
an Arc
and the resulting read guard has no lifetime requirements.
§impl<R, T> RwLock<R, T>where
R: RawRwLockRecursive,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockRecursive,
T: ?Sized,
pub fn read_recursive(&self) -> RwLockReadGuard<'_, R, T>
pub fn read_recursive(&self) -> RwLockReadGuard<'_, R, T>
Locks this RwLock
with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns.
Unlike read
, this method is guaranteed to succeed without blocking if
another read lock is held at the time of the call. This allows a thread
to recursively lock a RwLock
. However using this method can cause
writers to starve since readers no longer block if a writer is waiting
for the lock.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
pub fn try_read_recursive(&self) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive(&self) -> Option<RwLockReadGuard<'_, R, T>>
Attempts to acquire this RwLock
with shared read access.
If the access could not be granted at this time, then None
is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This method is guaranteed to succeed if another read lock is held at the
time of the call. See the documentation for read_recursive
for details.
This function does not block.
pub fn read_arc_recursive(self: &Arc<RwLock<R, T>>) -> ArcRwLockReadGuard<R, T>
pub fn read_arc_recursive(self: &Arc<RwLock<R, T>>) -> ArcRwLockReadGuard<R, T>
Locks this RwLock
with shared read access, through an Arc
.
This method is similar to the read_recursive
method; however, it requires the RwLock
to be inside of
an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_read_recursive_arc(
self: &Arc<RwLock<R, T>>,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_recursive_arc( self: &Arc<RwLock<R, T>>, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to lock this RwLock
with shared read access, through an Arc
.
This method is similar to the try_read_recursive
method; however, it requires the RwLock
to be inside
of an Arc
and the resulting read guard has no lifetime requirements.
§impl<R, T> RwLock<R, T>where
R: RawRwLockRecursiveTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockRecursiveTimed,
T: ?Sized,
pub fn try_read_recursive_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockReadGuard<'_, R, T>>
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, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
This method is guaranteed to succeed without blocking if another read
lock is held at the time of the call. See the documentation for
read_recursive
for details.
pub fn try_read_recursive_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockReadGuard<'_, R, T>>
pub fn try_read_recursive_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockReadGuard<'_, R, T>>
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, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
pub fn try_read_arc_recursive_for(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_arc_recursive_for( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to lock this RwLock
with read access until a timeout is reached, through an Arc
.
This method is similar to the try_read_recursive_for
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_read_arc_recursive_until(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<ArcRwLockReadGuard<R, T>>
pub fn try_read_arc_recursive_until( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<ArcRwLockReadGuard<R, T>>
Attempts to lock this RwLock
with read access until a timeout is reached, through an Arc
.
This method is similar to the try_read_recursive_until
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
§impl<R, T> RwLock<R, T>where
R: RawRwLockUpgrade,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockUpgrade,
T: ?Sized,
pub unsafe fn make_upgradable_guard_unchecked(
&self,
) -> RwLockUpgradableReadGuard<'_, R, T>
pub unsafe fn make_upgradable_guard_unchecked( &self, ) -> RwLockUpgradableReadGuard<'_, R, T>
Creates a new RwLockUpgradableReadGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds an upgradable read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget
.
pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T>
pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<'_, R, T>
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. There may be other readers currently inside the lock when this method returns.
Returns an RAII guard which will release this thread’s shared access once it is dropped.
pub fn try_upgradable_read(&self) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read(&self) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock
with upgradable read access.
If the access could not be granted at this time, then None
is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This function does not block.
pub unsafe fn make_upgradable_arc_guard_unchecked(
self: &Arc<RwLock<R, T>>,
) -> ArcRwLockUpgradableReadGuard<R, T>
pub unsafe fn make_upgradable_arc_guard_unchecked( self: &Arc<RwLock<R, T>>, ) -> ArcRwLockUpgradableReadGuard<R, T>
Creates a new ArcRwLockUpgradableReadGuard
without checking if the lock is held.
§Safety
This method must only be called if the thread logically holds an upgradable read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget
.`
pub fn upgradable_read_arc(
self: &Arc<RwLock<R, T>>,
) -> ArcRwLockUpgradableReadGuard<R, T>
pub fn upgradable_read_arc( self: &Arc<RwLock<R, T>>, ) -> ArcRwLockUpgradableReadGuard<R, T>
Locks this RwLock
with upgradable read access, through an Arc
.
This method is similar to the upgradable_read
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_upgradable_read_arc(
self: &Arc<RwLock<R, T>>,
) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
pub fn try_upgradable_read_arc( self: &Arc<RwLock<R, T>>, ) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
Attempts to lock this RwLock
with upgradable read access, through an Arc
.
This method is similar to the try_upgradable_read
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
§impl<R, T> RwLock<R, T>where
R: RawRwLockUpgradeTimed,
T: ?Sized,
impl<R, T> RwLock<R, T>where
R: RawRwLockUpgradeTimed,
T: ?Sized,
pub fn try_upgradable_read_for(
&self,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read_for( &self, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock
with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
pub fn try_upgradable_read_until(
&self,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
pub fn try_upgradable_read_until( &self, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<RwLockUpgradableReadGuard<'_, R, T>>
Attempts to acquire this RwLock
with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None
is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
pub fn try_upgradable_read_arc_for(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Duration,
) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
pub fn try_upgradable_read_arc_for( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Duration, ) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
Attempts to lock this RwLock
with upgradable access until a timeout is reached, through an Arc
.
This method is similar to the try_upgradable_read_for
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
pub fn try_upgradable_read_arc_until(
self: &Arc<RwLock<R, T>>,
timeout: <R as RawRwLockTimed>::Instant,
) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
pub fn try_upgradable_read_arc_until( self: &Arc<RwLock<R, T>>, timeout: <R as RawRwLockTimed>::Instant, ) -> Option<ArcRwLockUpgradableReadGuard<R, T>>
Attempts to lock this RwLock
with upgradable access until a timeout is reached, through an Arc
.
This method is similar to the try_upgradable_read_until
method; however, it requires the RwLock
to be
inside of an Arc
and the resulting read guard has no lifetime requirements.
Trait Implementations§
§impl<'de, R, T> Deserialize<'de> for RwLock<R, T>
impl<'de, R, T> Deserialize<'de> for RwLock<R, T>
§fn deserialize<D>(
deserializer: D,
) -> Result<RwLock<R, T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RwLock<R, T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<R, T> Serialize for RwLock<R, T>
impl<R, T> Serialize for RwLock<R, T>
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl<R, T> Send for RwLock<R, T>
impl<R, T> Sync for RwLock<R, T>
Auto Trait Implementations§
impl<R, T> !Freeze for RwLock<R, T>
impl<R, T> !RefUnwindSafe for RwLock<R, T>
impl<R, T> Unpin for RwLock<R, T>
impl<R, T> UnwindSafe for RwLock<R, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.