pub struct DynamicRcuLock<T> { /* private fields */ }Expand description
A synchronization wrapper that combines an RCU primitive T with a DynamicLockDepMutex to
serialize updates while permitting lock-free RCU reads, without using types for lock levels.
Readers access the underlying RCU value without acquiring the mutex via the read methods on
DynamicRcuLock. Writers must acquire the mutex via DynamicRcuLock::lock or
DynamicRcuLock::try_lock to obtain an RcuLockGuard, which grants exclusive writer
access to T.
Implementations§
Source§impl<T> DynamicRcuLock<T>
impl<T> DynamicRcuLock<T>
Sourcepub const fn new<L: LockLevel>(rcu: T) -> Self
pub const fn new<L: LockLevel>(rcu: T) -> Self
Creates a new DynamicRcuLock wrapping rcu at lock level L.
Sourcepub fn lock(&self) -> RcuLockGuard<'_, T>
pub fn lock(&self) -> RcuLockGuard<'_, T>
Acquires the update lock and returns a guard that allows updating the RCU cell.
Sourcepub fn try_lock(&self) -> Option<RcuLockGuard<'_, T>>
pub fn try_lock(&self) -> Option<RcuLockGuard<'_, T>>
Attempts to acquire the update lock without blocking.
Source§impl<T: Send + Sync + 'static> DynamicRcuLock<RcuArc<T>>
impl<T: Send + Sync + 'static> DynamicRcuLock<RcuArc<T>>
Source§impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuArray<T>>
impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuArray<T>>
Sourcepub fn get<'a>(&self, scope: &'a RcuReadScope, index: usize) -> Option<&'a T>
pub fn get<'a>(&self, scope: &'a RcuReadScope, index: usize) -> Option<&'a T>
Returns a reference to the element at index, or None if index is out of bounds.
Sourcepub fn as_slice<'a>(&self, scope: &'a RcuReadScope) -> &'a [T]
pub fn as_slice<'a>(&self, scope: &'a RcuReadScope) -> &'a [T]
Returns a slice containing the entire array bound to scope.
Source§impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuBox<T>>
impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuBox<T>>
Sourcepub fn read(&self) -> RcuReadGuard<T>
pub fn read(&self) -> RcuReadGuard<T>
Reads the value of the wrapped RcuBox without acquiring the update lock.
Sourcepub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> &'a T
pub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> &'a T
Returns a reference to the value of the wrapped RcuBox bound to scope.
Source§impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuDroppableArc<T>>
impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuDroppableArc<T>>
Sourcepub fn read(&self) -> RcuReadGuard<T>
pub fn read(&self) -> RcuReadGuard<T>
Reads the value of the wrapped RcuDroppableArc without acquiring the update lock.
Sourcepub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> &'a T
pub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> &'a T
Returns a reference to the value of the wrapped RcuDroppableArc bound to scope.
Sourcepub fn to_arc(&self) -> Arc<T> ⓘ
pub fn to_arc(&self) -> Arc<T> ⓘ
Creates a new Arc<T> referencing the same object as the underlying RcuDroppableArc.
Source§impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuOptionArc<T>>
impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuOptionArc<T>>
Sourcepub fn read(&self) -> Option<RcuReadGuard<T>>
pub fn read(&self) -> Option<RcuReadGuard<T>>
Reads the value of the wrapped RcuOptionArc without acquiring the update lock.
Sourcepub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> Option<&'a T>
pub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> Option<&'a T>
Returns a reference to the value of the wrapped RcuOptionArc bound to scope.
Sourcepub fn to_option_arc(&self) -> Option<Arc<T>>
pub fn to_option_arc(&self) -> Option<Arc<T>>
Creates a new Option<Arc<T>> referencing the same object as the underlying
RcuOptionArc.
Source§impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuOptionBox<T>>
impl<T: RcuDroppable + Sync> DynamicRcuLock<RcuOptionBox<T>>
Sourcepub fn read(&self) -> Option<RcuReadGuard<T>>
pub fn read(&self) -> Option<RcuReadGuard<T>>
Reads the value of the wrapped RcuOptionBox without acquiring the update lock.
Sourcepub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> Option<&'a T>
pub fn as_ref<'a>(&self, scope: &'a RcuReadScope) -> Option<&'a T>
Returns a reference to the value of the wrapped RcuOptionBox bound to scope.
Sourcepub fn is_some(&self, scope: &RcuReadScope) -> bool
pub fn is_some(&self, scope: &RcuReadScope) -> bool
Returns true if the underlying RcuOptionBox currently contains a value.
Sourcepub fn is_none(&self, scope: &RcuReadScope) -> bool
pub fn is_none(&self, scope: &RcuReadScope) -> bool
Returns true if the underlying RcuOptionBox does not contain a value.
Sourcepub fn cloned(&self) -> Option<T>where
T: Clone,
pub fn cloned(&self) -> Option<T>where
T: Clone,
Returns a clone of the value of the wrapped RcuOptionBox.
Source§impl<T: Send + Sync + 'static> DynamicRcuLock<RcuWeak<T>>
impl<T: Send + Sync + 'static> DynamicRcuLock<RcuWeak<T>>
Sourcepub fn ptr_eq(&self, other: &Weak<T>) -> bool
pub fn ptr_eq(&self, other: &Weak<T>) -> bool
Returns true if the wrapped weak pointer points to the same allocation as other.
Sourcepub fn strong_count(&self, scope: &RcuReadScope) -> usize
pub fn strong_count(&self, scope: &RcuReadScope) -> usize
Returns the number of strong (Arc) pointers pointing to the allocation.
Trait Implementations§
Source§impl<T: Debug> Debug for DynamicRcuLock<T>
impl<T: Debug> Debug for DynamicRcuLock<T>
Source§impl<T> MutexLike for DynamicRcuLock<T>
impl<T> MutexLike for DynamicRcuLock<T>
type Guard<'a> = RcuLockGuard<'a, T> where T: 'a
type Context = <DynamicLockDepMutex<()> as MutexLike>::Context
fn context() -> Self::Context
Source§fn lock(&self, context: &mut Self::Context) -> Self::Guard<'_>
fn lock(&self, context: &mut Self::Context) -> Self::Guard<'_>
level is the index of the locked mutex in the lock ordering.fn key(&self) -> *const ()where
Self: Sized,
impl<T> RcuDroppable for DynamicRcuLock<T>
Source§impl<T> ResetDependencies for DynamicRcuLock<T>
impl<T> ResetDependencies for DynamicRcuLock<T>
Source§unsafe fn reset_dependencies(&self)
unsafe fn reset_dependencies(&self)
Auto Trait Implementations§
impl<T> !Freeze for DynamicRcuLock<T>
impl<T> !RefUnwindSafe for DynamicRcuLock<T>
impl<T> Send for DynamicRcuLock<T>where
T: Send,
impl<T> Sync for DynamicRcuLock<T>where
T: Sync,
impl<T> Unpin for DynamicRcuLock<T>where
T: Unpin,
impl<T> UnsafeUnpin for DynamicRcuLock<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for DynamicRcuLock<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
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 more