WaterMark

Struct WaterMark 

Source
pub struct WaterMark { /* private fields */ }
Available on crate feature 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

  1. as many times as begin(k) has, AND
  2. 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

Source

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.

Source

pub fn name(&self) -> &str

Returns the name of the watermark.

Source

pub fn init(&mut self, closer: Closer)

Initializes a WaterMark struct. MUST be called before using it.

Source

pub fn begin(&self, index: u64) -> Result<(), WaterMarkError>

Sets the last index to the given value.

Source

pub fn begin_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>

Works like [begin] but accepts multiple indices.

Source

pub fn done(&self, index: u64) -> Result<(), WaterMarkError>

Sets a single index as done.

Source

pub fn done_many(&self, indices: MediumVec<u64>) -> Result<(), WaterMarkError>

Sets multiple indices as done.

Source

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.

Source

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.

Source

pub fn last_index(&self) -> Result<u64, WaterMarkError>

Returns the last index for which begin has been called.

Source

pub fn wait_for_mark(&self, index: u64) -> Result<(), WaterMarkError>

Waits until the given index is marked as done.

Trait Implementations§

Source§

impl Debug for WaterMark

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more