pub struct WaterMark { /* private fields */ }std only.Expand description
WaterMark is used to keep track of the minimum un-finished index. Typically, an index k becomes
finished or “done” according to a WaterMark once done(k) has been called
- as many times as
begin(k)has, AND - a positive number of times.
An index may also become “done” by calling set_done_until at a time such that it is not
inter-mingled with begin/done calls.
Since done_until and last_index addresses are passed to sync/atomic packages, we ensure that they
are 64-bit aligned by putting them at the beginning of the structure.
Implementations§
Source§impl WaterMark
impl WaterMark
Sourcepub fn new(name: Cow<'static, str>) -> Self
pub fn new(name: Cow<'static, str>) -> Self
Create a new WaterMark with the given name.
Note: Before using the watermark, you must call init to start the background thread.
Sourcepub fn init(&mut self, closer: Closer)
pub fn init(&mut self, closer: Closer)
Initializes a WaterMark struct. MUST be called before using it.
Sourcepub fn begin(&self, index: u64) -> Result<(), WaterMarkError>
pub fn begin(&self, index: u64) -> Result<(), WaterMarkError>
Sets the last index to the given value.
Sourcepub fn begin_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>
pub fn begin_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>
Works like [begin] but accepts multiple indices.
Sourcepub fn done_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>
pub fn done_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>
Sets multiple indices as done.
Sourcepub fn done_until(&self) -> Result<u64, WaterMarkError>
pub fn done_until(&self) -> Result<u64, WaterMarkError>
Returns the maximum index that has the property that all indices less than or equal to it are done.
Sourcepub fn set_done_util(&self, val: u64) -> Result<(), WaterMarkError>
pub fn set_done_util(&self, val: u64) -> Result<(), WaterMarkError>
Sets the maximum index that has the property that all indices less than or equal to it are done.
Sourcepub fn last_index(&self) -> Result<u64, WaterMarkError>
pub fn last_index(&self) -> Result<u64, WaterMarkError>
Returns the last index for which begin has been called.
Sourcepub fn wait_for_mark(&self, index: u64) -> Result<(), WaterMarkError>
pub fn wait_for_mark(&self, index: u64) -> Result<(), WaterMarkError>
Waits until the given index is marked as done.