pub struct WriteHandle<O, T, A>where
O: Apply<T, A>,{ /* private fields */ }Expand description
A writer handle to a left-right guarded data structure.
All operations on the underlying data should be enqueued as operations of type O using
append. The effect of this operations are only exposed to readers once
publish is called.
§Reading through a WriteHandle
WriteHandle allows access to a ReadHandle through Deref<Target = ReadHandle>. Note that
since the reads go through a ReadHandle, those reads are subject to the same visibility
restrictions as reads that do not go through the WriteHandle: they only see the effects of
operations prior to the last call to publish.
Implementations§
Source§impl<O, T, A> WriteHandle<O, T, A>where
O: Apply<T, A>,
impl<O, T, A> WriteHandle<O, T, A>where
O: Apply<T, A>,
Sourcepub fn publish(&mut self) -> &mut Self
pub fn publish(&mut self) -> &mut Self
Publish all operations append to the log to reads.
This method needs to wait for all readers to move to the “other” copy of the data so that it can replay the operational log onto the stale copy the readers used to use. This can take some time, especially if readers are executing slow operations, or if there are many of them.
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Publish as necessary to ensure that all operations are visible to readers.
WriteHandle::publish will always wait for old readers to depart and swap the maps.
This method will only do so if there are pending operations.
Sourcepub fn has_pending_operations(&self) -> bool
pub fn has_pending_operations(&self) -> bool
Returns true if there are operations in the operational log that have not yet been exposed to readers.
Sourcepub fn append(&mut self, op: O) -> &mut Self
pub fn append(&mut self, op: O) -> &mut Self
Append the given operation to the operational log.
Its effects will not be exposed to readers until you call publish.
Sourcepub fn auxiliary_mut(&mut self) -> &mut A
pub fn auxiliary_mut(&mut self) -> &mut A
Returns a mutable reference to the auxiliary data structure.
Methods from Deref<Target = ReadHandle<T>>§
Sourcepub fn factory(&self) -> ReadHandleFactory<T>
pub fn factory(&self) -> ReadHandleFactory<T>
Create a ReadHandleFactory which is Send & Sync and can be shared across threads to create
additional ReadHandle instances.
Sourcepub fn enter(&self) -> Option<ReadGuard<'_, T>>
pub fn enter(&self) -> Option<ReadGuard<'_, T>>
Take out a guarded live reference to the read copy of the T.
While the guard lives, the WriteHandle cannot proceed with a call to
WriteHandle::publish, so no queued operations will become visible to any reader.
If the WriteHandle has been dropped, this function returns None.
Sourcepub fn was_dropped(&self) -> bool
pub fn was_dropped(&self) -> bool
Returns true if the WriteHandle has been dropped.
Sourcepub fn raw_handle(&self) -> Option<NonNull<T>>
pub fn raw_handle(&self) -> Option<NonNull<T>>
Returns a raw pointer to the read copy of the data.
Note that it is only safe to read through this pointer if you know that the writer will
not start writing into it. This is most likely only the case if you are calling this method
from inside a method that holds &mut WriteHandle.
Casting this pointer to &mut is never safe.
Trait Implementations§
Source§impl<O, T, A> Debug for WriteHandle<O, T, A>
impl<O, T, A> Debug for WriteHandle<O, T, A>
Source§impl<O, T, A> Deref for WriteHandle<O, T, A>where
O: Apply<T, A>,
impl<O, T, A> Deref for WriteHandle<O, T, A>where
O: Apply<T, A>,
Source§impl<O, T, A> Drop for WriteHandle<O, T, A>where
O: Apply<T, A>,
impl<O, T, A> Drop for WriteHandle<O, T, A>where
O: Apply<T, A>,
Source§impl<O, T, A> Extend<O> for WriteHandle<O, T, A>where
O: Apply<T, A>,
impl<O, T, A> Extend<O> for WriteHandle<O, T, A>where
O: Apply<T, A>,
Source§fn extend<I>(&mut self, ops: I)where
I: IntoIterator<Item = O>,
fn extend<I>(&mut self, ops: I)where
I: IntoIterator<Item = O>,
Add multiple operations to the operational log.
Their effects will not be exposed to readers until you call publish
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)