pub struct RcuOptionArc<T: Send + Sync + 'static> { /* private fields */ }Expand description
An RCU (Read-Copy-Update) wrapper around Option<Arc<T>>.
The Arc can be dereferenced from multiple threads concurrently without blocking. When the Arc is replaced, reads may continue to see the old Arc pointer for some period of time.
Implementations§
Source§impl<T: Send + Sync + 'static> RcuOptionArc<T>
impl<T: Send + Sync + 'static> RcuOptionArc<T>
Sourcepub fn read(&self) -> Option<RcuReadGuard<T>>
pub fn read(&self) -> Option<RcuReadGuard<T>>
Read the value of the wrapped Arc, if present.
The object referenced by the RCU Arc will remain valid until the RcuReadGuard is dropped.
However, another thread running concurrently might see a different value for the object.
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 Arc, if present.
The object referenced by the RCU Arc will remain valid until the RcuReadScope is dropped.
However, another thread running concurrently might see a different value for the object.
Sourcepub fn update(&self, data: Option<Arc<T>>)
pub fn update(&self, data: Option<Arc<T>>)
Write a new Option<Arc<T>> to the RCU wrapper.
Concurrent readers may continue to see the old Arc pointer until the RCU state machine has made sufficient progress to ensure that no concurrent readers are holding read guards.
Sourcepub fn to_option_arc(&self) -> Option<Arc<T>>
pub fn to_option_arc(&self) -> Option<Arc<T>>
Create a new Arc<T> to the object referenced by the wrapped Arc, if present.
This function returns a new Option<Arc<T>> to the object referenced by the wrapped Arc,
potentially increasing the reference count of the object by one.