pub struct AckTicket { /* private fields */ }Expand description
Durability handle associated with the write operation
§Epoch
Every ticket is assigned a monotonically increasing epoch to moniter durability
§Durability Guarantee
If wanted, the ticket could be awaited to poll till the epoch becomes durable.
Once a await on ticket is completed successfully, all writes assigned to earlier epochs are also guaranteed to be durable.
NOTE: Using await is optional. Callers that only require fire-and-forget semantics may
simply discard the returned ticket.
Implementations§
Source§impl AckTicket
impl AckTicket
Sourcepub const fn new(epoch: TEpoch, completion: Arc<Completion>) -> Self
pub const fn new(epoch: TEpoch, completion: Arc<Completion>) -> Self
Sourcepub fn wait(&self) -> FrozenResult<TEpoch>
pub fn wait(&self) -> FrozenResult<TEpoch>
Blocks the current thread unitl the AckTicket becomes durable
If a durability error is reported before the epoch becomes durable, the corresponding
FrozenError is returned instead.
§Example
use frozen_core::ack::{AckTicket, Completion};
use std::{sync::Arc, thread, time};
let completion = Arc::new(Completion::default());
let epoch = completion.increment_current_epoch();
let ticket = AckTicket::new(epoch, completion.clone());
thread::spawn({
let completion = completion.clone();
move || {
thread::sleep(time::Duration::from_millis(10));
completion.mark_epoch_as_durable(epoch);
completion.notify_all_listeners();
}
});
assert_eq!(ticket.wait().unwrap(), epoch);Trait Implementations§
Auto Trait Implementations§
impl Freeze for AckTicket
impl RefUnwindSafe for AckTicket
impl Send for AckTicket
impl Sync for AckTicket
impl Unpin for AckTicket
impl UnsafeUnpin for AckTicket
impl UnwindSafe for AckTicket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more