pub struct SynchronizedWriterRcu<T> { /* private fields */ }
Expand description
An RCU (Read-Copy-Update) data structure that uses a Mutex
to synchronize
writers.
Implementations§
Source§impl<T> SynchronizedWriterRcu<T>
impl<T> SynchronizedWriterRcu<T>
Sourcepub fn write(&self) -> WriteGuard<'_, T>where
T: Clone,
pub fn write(&self) -> WriteGuard<'_, T>where
T: Clone,
Acquires a write guard on the RCU by cloning T
.
See [`WriteGuard::write_with``].
Sourcepub fn write_with<F: FnOnce(&T) -> T>(&self, f: F) -> WriteGuard<'_, T>
pub fn write_with<F: FnOnce(&T) -> T>(&self, f: F) -> WriteGuard<'_, T>
Acquires a write guard on the RCU.
[WriteGuard
] provides mutable access to a new copy of the data kept by
SingleWriterRcu
via f
.
Dropping the returned [WriteGuard
] commits any changes back to the
RCU. Changes may be discarded with [WriteGuard::discard
].
Sourcepub fn replace(&self, value: T)
pub fn replace(&self, value: T)
Replaces the value in the RCU with value
without reading the current
value.
WARNING: do NOT use this method with a value built from a clone of
the data from [SingleWriterRcu::read
], this is only meant to be used
when the new value is produced independently of the previous value. The
value may be changed by another thread between read
and replace
-
these changes would be lost. Use [SingleWriterRcu::write
] to ensure
writer synchronization is applied.
Trait Implementations§
Source§impl<T: Default> Default for SynchronizedWriterRcu<T>
impl<T: Default> Default for SynchronizedWriterRcu<T>
Source§fn default() -> SynchronizedWriterRcu<T>
fn default() -> SynchronizedWriterRcu<T>
Auto Trait Implementations§
impl<T> !Freeze for SynchronizedWriterRcu<T>
impl<T> RefUnwindSafe for SynchronizedWriterRcu<T>where
T: RefUnwindSafe,
impl<T> Send for SynchronizedWriterRcu<T>
impl<T> Sync for SynchronizedWriterRcu<T>
impl<T> Unpin for SynchronizedWriterRcu<T>
impl<T> UnwindSafe for SynchronizedWriterRcu<T>where
T: RefUnwindSafe,
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
Source§impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
§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,
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