pub struct HlcTimestamp(pub u64);Expand description
Hybrid Logical Clock for monotonic timestamps
Format: [48-bit physical time | 16-bit logical counter]
Properties:
- Monotonically increasing
- Causally ordered
- Resolution: 65,536 events per millisecond
Tuple Fields§
§0: u64Implementations§
Source§impl HlcTimestamp
impl HlcTimestamp
Sourcepub fn new(physical_ms: u64, logical: u16) -> Self
pub fn new(physical_ms: u64, logical: u16) -> Self
Create timestamp from physical time (ms) and logical counter
Sourcepub fn physical_ms(&self) -> u64
pub fn physical_ms(&self) -> u64
Get physical time component (milliseconds since epoch)
Sourcepub fn allocate_next(last: &AtomicU64) -> Self
pub fn allocate_next(last: &AtomicU64) -> Self
Allocate next timestamp (atomic, lock-free)
Algorithm:
- Read current physical time
- If physical > last_physical: reset logical to 0
- Else: increment logical counter
- CAS to update, retry on conflict
Sourcepub fn read_current(ts: &AtomicU64) -> Self
pub fn read_current(ts: &AtomicU64) -> Self
Read current timestamp without advancing
Trait Implementations§
Source§impl Clone for HlcTimestamp
impl Clone for HlcTimestamp
Source§fn clone(&self) -> HlcTimestamp
fn clone(&self) -> HlcTimestamp
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for HlcTimestamp
Source§impl Debug for HlcTimestamp
impl Debug for HlcTimestamp
impl Eq for HlcTimestamp
Source§impl From<HlcTimestamp> for u64
impl From<HlcTimestamp> for u64
Source§fn from(ts: HlcTimestamp) -> Self
fn from(ts: HlcTimestamp) -> Self
Converts to this type from the input type.
Source§impl From<u64> for HlcTimestamp
impl From<u64> for HlcTimestamp
Source§impl Ord for HlcTimestamp
impl Ord for HlcTimestamp
Source§fn cmp(&self, other: &HlcTimestamp) -> Ordering
fn cmp(&self, other: &HlcTimestamp) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
Source§fn eq(&self, other: &HlcTimestamp) -> bool
fn eq(&self, other: &HlcTimestamp) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
impl StructuralPartialEq for HlcTimestamp
Auto Trait Implementations§
impl Freeze for HlcTimestamp
impl RefUnwindSafe for HlcTimestamp
impl Send for HlcTimestamp
impl Sync for HlcTimestamp
impl Unpin for HlcTimestamp
impl UnsafeUnpin for HlcTimestamp
impl UnwindSafe for HlcTimestamp
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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