pub trait Rcu {
type Item;
type Pool: EpochCounterPool;
// Required methods
fn new(
initial: impl Into<Arc<Self::Item>>,
epoch_counter_pool: Self::Pool
) -> Self;
fn replace(&self, new_value: impl Into<Arc<Self::Item>>) -> Arc<Self::Item>;
unsafe fn raw_read(&self, epoch_counter: &EpochCounter) -> Arc<Self::Item>;
unsafe fn raw_try_update(
&self,
update: impl FnMut(&Self::Item) -> Option<Arc<Self::Item>>,
epoch_counter: &EpochCounter
) -> Option<Arc<Self::Item>>;
}
Required Associated Types§
type Item
type Pool: EpochCounterPool
Required Methods§
fn new( initial: impl Into<Arc<Self::Item>>, epoch_counter_pool: Self::Pool ) -> Self
sourcefn replace(&self, new_value: impl Into<Arc<Self::Item>>) -> Arc<Self::Item>
fn replace(&self, new_value: impl Into<Arc<Self::Item>>) -> Arc<Self::Item>
Replace the Rcu’s content with a new value
This does not synchronize writes and the last to update the active_value pointer wins.
all writes that do not win will be lost, though not leaked. This will block until the old value can be reclaimed, i.e. all threads witnessed to be in the read critical sections have been witnessed to have left the critical section at least once
sourceunsafe fn raw_read(&self, epoch_counter: &EpochCounter) -> Arc<Self::Item>
unsafe fn raw_read(&self, epoch_counter: &EpochCounter) -> Arc<Self::Item>
§Safety
- The epoch counter must not be used concurrently
- The epoch counter must belong to the EpochCounterPool of this Rcu
sourceunsafe fn raw_try_update(
&self,
update: impl FnMut(&Self::Item) -> Option<Arc<Self::Item>>,
epoch_counter: &EpochCounter
) -> Option<Arc<Self::Item>>
unsafe fn raw_try_update( &self, update: impl FnMut(&Self::Item) -> Option<Arc<Self::Item>>, epoch_counter: &EpochCounter ) -> Option<Arc<Self::Item>>
Update the Rcu using the provided update function Retries when the Rcu has been updated/replaced between reading the old value and writing the new value Aborts when the update function returns None
§Safety
- The epoch counter must not be used concurrently
- The epoch counter must belong to the EpochCounterPool of this Rcu
Object Safety§
This trait is not object safe.
Implementors§
source§impl<T, P: EpochCounterPool> Rcu for arcu::atomic::Arcu<T, P>
impl<T, P: EpochCounterPool> Rcu for arcu::atomic::Arcu<T, P>
##Safety
- When mixing safe and unsafe functions care needs to be taken that write operations see all Epochs used by concurrent read operations
- The safe read operations assume that the writer will observe
epoch_counters::THREAD_EPOCH_COUNTER
, seeepoch_counters::with_thread_local_epoch_counter
. - The safe writers assume that the readers will use one of the epoch counters in
epoch_counters::GLOBAL_EPOCH_COUNTERS
, seeepoch_counters::register_epoch_counter
.