[][src]Struct wrrm::Wrrm

pub struct Wrrm<T> { /* fields omitted */ }

"Write-rarely-read-many" wrapper.

Implementation details

This container contains more or less the equivalent of an Atomic<Arc<T>>. Accessing T is quite cheap, as it only consists in cloning the Arc. Modifying T can be done by performing a deep clone of T, then storing a pointer to the updated version in the Atomic.

If N threads try to update the T at the same time, the entire update of T might need to be performed more than N times. For example, if two threads try to update T at the same time, one of them will win and perform the update. When trying to apply its own update, the other thread will detect that the T has been touched in-between and will restart its own update from scratch.

Implementations

impl<T> Wrrm<T>[src]

pub fn new(value: T) -> Self[src]

Creates a new Wrrm.

pub fn access(&self) -> Access<T>[src]

Grants shared access to the content.

This Access struct will always point to the same, potentially stale, version. In other words, if the content of the Wrrm is updated while an Access is alive, this Access will still point to the old version.

pub fn modify_with(&self, modification: impl FnMut(&mut T)) where
    T: Clone
[src]

Modifies the value using the given function.

The function will be passed a mutable reference to a copy of the value currently stored in the container.

Note: The function might be called multiple times, with new copies every time, in situations where multiple threads are competing for an update. You are expected to perform the same modification on the value every time.

Trait Implementations

impl<T> Debug for Wrrm<T> where
    T: Debug
[src]

impl<T: Default> Default for Wrrm<T>[src]

impl<T> From<T> for Wrrm<T>[src]

Auto Trait Implementations

impl<T> Send for Wrrm<T> where
    T: Send + Sync

impl<T> Sync for Wrrm<T> where
    T: Send + Sync

impl<T> Unpin for Wrrm<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.