Skip to main content

Completion

Struct Completion 

Source
pub struct Completion { /* private fields */ }
Expand description

A shared durability acknowledgement state used for issuing AckTicket’s

The completion state tracks following things:

  • The latest assigned epoch
  • The latest durable epoch
  • Waiters blocked on durability advancement
  • Durability errors (if any) blocking durability progress

§Example

use frozen_core::ack::Completion;

let completion = Completion::default();

assert_eq!(completion.read_current_epoch(), 0);
assert_eq!(completion.read_durable_epoch(), 0);

Implementations§

Source§

impl Completion

Source

pub fn increment_current_epoch(&self) -> TEpoch

Advance current and return next durability epoch

NOTE: Epoch value is monotonically increasing and used to identify unique write operations.

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();

assert_eq!(completion.increment_current_epoch(), 1);
assert_eq!(completion.increment_current_epoch(), 2);
assert_eq!(completion.increment_current_epoch(), 3);
Source

pub fn mark_epoch_as_durable(&self, epoch: TEpoch)

Mark given TEpoch as durable

NOTE: Once an epoch is marked durable, all earlier epochs are implicitly understood to be durable.

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();
completion.mark_epoch_as_durable(0x0A);

assert_eq!(completion.read_durable_epoch(), 0x0A);
Source

pub fn get_err(&self) -> Option<FrozenError>

Fetch the acknowledgement error (if any)

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();
assert_eq!(completion.get_err(), None);
Source

pub fn set_err(&self, new_error: FrozenError)

Update current acknowledgement error w/ a new FrozenError

§Example
use frozen_core::{ack::Completion, error::{FrozenError, ErrCode}};

let completion = Completion::default();
let new_error = FrozenError::new(0x10, 0x20, ErrCode::new(0x30, "io"), "failed to read file");

completion.set_err(new_error.clone());
assert_eq!(completion.get_err(), Some(new_error));
Source

pub fn del_err(&self)

Clear acknowledgement error by replacing the underying error w/ an empty pointer

§Example
use frozen_core::{ack::Completion, error::{FrozenError, ErrCode}};

let completion = Completion::default();
let new_error = FrozenError::new(0x10, 0x20, ErrCode::new(0x30, "io"), "failed to read file");

completion.set_err(new_error.clone());
assert!(completion.get_err().is_some());

completion.del_err();
assert!(completion.get_err().is_none());
Source

pub fn read_current_epoch(&self) -> TEpoch

Read the latest assigned epoch

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();
completion.increment_current_epoch();

assert_eq!(completion.read_current_epoch(), 1);
Source

pub fn read_durable_epoch(&self) -> TEpoch

Read the latest durable epoch

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();
completion.mark_epoch_as_durable(0x3A);

assert_eq!(completion.read_durable_epoch(), 0x3A);
Source

pub fn notify_all_listeners(&self)

Wake all the listeners currently waiting for durability progress

NOTE: Waking listeners does not modify any durable state and are typically called after advancing the durable epoch or after occurence of [AckError].

§Example
use frozen_core::ack::Completion;

let completion = Completion::default();
completion.notify_all_listeners();

Trait Implementations§

Source§

impl Debug for Completion

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Completion

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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.