pub struct RcuPtr<T> { /* private fields */ }Expand description
A pointer managed by the RCU state machine.
This pointer can be read from multiple threads concurrently without blocking. When the pointer is written, reads may continue to see the old value of the pointer for some period of time.
Callers are responsible managing the lifetime of the object referenced by the pointer. When the
the pointer value is written, the caller should typically use rcu_call or rcu_drop to defer
cleanup of the object referenced by the old pointer value until the RCU state machine has made
sufficient progress to ensure that no concurrent readers are holding read guards.
Implementations§
Source§impl<T> RcuPtr<T>
impl<T> RcuPtr<T>
Sourcepub fn get(&self) -> RcuReadGuard<T>
pub fn get(&self) -> RcuReadGuard<T>
Get the value pointed to by the RCU pointer.
If the RCU pointer is null, this function will panic.
The object referenced by the RCU pointer will remain valid until the RcuReadGuard is
dropped. However, another thread running concurrently might see a different value for the
object.
Sourcepub fn maybe_get(&self) -> Option<RcuReadGuard<T>>
pub fn maybe_get(&self) -> Option<RcuReadGuard<T>>
Get the value pointed to by the RCU pointer.
If the RCU pointer is null, this function will return None.
The object referenced by the RCU pointer will remain valid until the RcuReadGuard is
dropped. However, another thread running concurrently might see a different value for the
object.
Sourcepub fn read<'a>(&self, scope: &'a RcuReadScope) -> RcuPtrRef<'a, T>
pub fn read<'a>(&self, scope: &'a RcuReadScope) -> RcuPtrRef<'a, T>
Read the value of the RCU pointer.
The returned pointer will remain valid until the RcuReadScope is dropped. However, another
thread running concurrently might see a different value for the object.
Sourcepub fn assign(&self, ptr: *mut T)
pub fn assign(&self, ptr: *mut T)
Assign a new value to the RCU pointer.
Concurrent readers may continue to see the old value of the pointer until the RCU state
machine has made sufficient progress. To wait until all concurrent readers have dropped
their read guards, call rcu_synchronize().
Sourcepub fn assign_ptr(&self, ptr: RcuPtrRef<'_, T>)
pub fn assign_ptr(&self, ptr: RcuPtrRef<'_, T>)
Assign a new value to the RCU pointer.
Concurrent readers may continue to see the old value of the pointer until the RCU state
machine has made sufficient progress. To wait until all concurrent readers have dropped
their read guards, call rcu_synchronize().
Sourcepub fn replace(&self, ptr: *mut T) -> *mut T
pub fn replace(&self, ptr: *mut T) -> *mut T
Replace the value of the RCU pointer.
Concurrent readers may continue to see the old value of the pointer until the RCU state
machine has made sufficient progress. To wait until all concurrent readers have dropped
their read guards, call rcu_synchronize().
Sourcepub fn replace_ptr(&self, ptr: RcuPtrRef<'_, T>) -> *mut T
pub fn replace_ptr(&self, ptr: RcuPtrRef<'_, T>) -> *mut T
Replace the value of the RCU pointer.
Concurrent readers may continue to see the old value of the pointer until the RCU state
machine has made sufficient progress. To wait until all concurrent readers have dropped
their read guards, call rcu_synchronize().