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
impl Completion
Sourcepub fn increment_current_epoch(&self) -> TEpoch
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);Sourcepub fn mark_epoch_as_durable(&self, epoch: TEpoch)
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);Sourcepub fn get_err(&self) -> Option<FrozenError>
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);Sourcepub fn set_err(&self, new_error: FrozenError)
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));Sourcepub fn del_err(&self)
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());Sourcepub fn read_current_epoch(&self) -> TEpoch
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);Sourcepub fn read_durable_epoch(&self) -> TEpoch
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);Sourcepub fn notify_all_listeners(&self)
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();