Skip to main content

Completion

Struct Completion 

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

A shared durability acknowledgement state used for issuing AckTicket

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

let completion = frozen_core::ack::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

§Epoch

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

§Example
let completion = frozen_core::ack::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

§Monotonic Epoch

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 (i.e. replace) 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 underlying error w/ None

§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 listeners currently waiting for durability progress

Waking listeners does not modify any durable state and is typically called after advancing the durable epoch or setting an error

§Example
use frozen_core::ack::Completion;

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

pub fn set_sync_trigger(&self, trigger: Weak<dyn SyncTrigger>)

Register a SyncTrigger implementation for triggering syncs

Source

pub fn trigger_sync(&self) -> FrozenResult<()>

Trigger synchronization using the registered SyncTrigger

Source

pub fn wait_for_epoch(&self, epoch: TEpoch) -> FrozenResult<TEpoch>

Blocks the current thread until the specified epoch becomes durable or an error is reported

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.