Struct MemClock

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

A thread safe implementation of a lamport clock. It uses efficient atomic operations for all of its functions.

Implementations§

Source§

impl MemClock

Source

pub fn new() -> Self

Create a new MemClock. The starting value is 1.

Source

pub fn new_with_value(value: u64) -> Self

Creates a new in memory clock, with the initial time value of value.

§Panics

If the value is invalid (i.e., the value is equal to 0).

Trait Implementations§

Source§

impl Clock for MemClock

Source§

type IncrementError = Infallible

The Error returned, when trying to increment this clock.
Source§

type WitnessError = Infallible

The Error returned, when trying to witness this clock.
Source§

fn time(&self) -> Time

Get the current value of this clock.
Source§

fn increment(&mut self) -> Result<Time, Self::IncrementError>

Return the current value and increment it internally. Read more
Source§

fn witness(&mut self, time: Time) -> Result<(), Self::WitnessError>

Update our clock based on another processes clock’s value, we “witnessed”. Read more
Source§

impl Debug for MemClock

Source§

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

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

impl Default for MemClock

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,