pub struct LamportClock(/* private fields */);Expand description
A thread safe implementation of a lamport clock. It uses efficient atomic operations for all of its functions, falling back to a heavy lock only if there are enough CAS failures.
Implementations§
Source§impl LamportClock
impl LamportClock
Sourcepub fn new() -> LamportClock
pub fn new() -> LamportClock
Creates a new lamport clock with the given initial value
Sourcepub fn time(&self) -> LamportTime
pub fn time(&self) -> LamportTime
Return the current value of the lamport clock
Sourcepub fn increment(&self) -> LamportTime
pub fn increment(&self) -> LamportTime
Increment and return the value of the lamport clock
Sourcepub fn witness(&self, time: LamportTime)
pub fn witness(&self, time: LamportTime)
Witness is called to update our local clock if necessary after witnessing a clock value received from another process
Trait Implementations§
Source§impl Clone for LamportClock
impl Clone for LamportClock
Source§fn clone(&self) -> LamportClock
fn clone(&self) -> LamportClock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LamportClock
impl Debug for LamportClock
Source§impl Default for LamportClock
impl Default for LamportClock
Source§fn default() -> LamportClock
fn default() -> LamportClock
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LamportClock
impl RefUnwindSafe for LamportClock
impl Send for LamportClock
impl Sync for LamportClock
impl Unpin for LamportClock
impl UnwindSafe for LamportClock
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more