Show / Hide Table of Contents

Struct RumorTimestamp

Represents Lamport timestamp of the rumor mixed with the timestamp returned by the local clock.

Implements
IEquatable<RumorTimestamp>
IBinaryFormattable<RumorTimestamp>
IComparable<RumorTimestamp>
Inherited Members
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: DotNext.Net.Cluster.Messaging.Gossip
Assembly: DotNext.Net.Cluster.dll
Syntax
public readonly struct RumorTimestamp : IEquatable<RumorTimestamp>, IBinaryFormattable<RumorTimestamp>, IComparable<RumorTimestamp>

Constructors

View Source

RumorTimestamp()

Generates a new fresh timestamp.

Declaration
public RumorTimestamp()
View Source

RumorTimestamp(ReadOnlySpan<byte>)

Decodes the timestamp from a sequence of bytes.

Declaration
public RumorTimestamp(ReadOnlySpan<byte> bytes)
Parameters
Type Name Description
ReadOnlySpan<byte> bytes

The buffer containing encoded timestamp.

Exceptions
Type Condition
ArgumentOutOfRangeException

The length of bytes is less than Size.

Properties

View Source

MaxValue

Gets the maximum possible value of the timestamp.

Declaration
public static RumorTimestamp MaxValue { get; }
Property Value
Type Description
RumorTimestamp
View Source

MinValue

Gets the minimum possible value of the timestamp.

Declaration
public static RumorTimestamp MinValue { get; }
Property Value
Type Description
RumorTimestamp

Methods

View Source

CompareTo(RumorTimestamp)

Compares this timestamp with another one.

Declaration
public int CompareTo(RumorTimestamp other)
Parameters
Type Name Description
RumorTimestamp other

The timestamp to compare.

Returns
Type Description
int

The comparison result.

View Source

Equals(RumorTimestamp)

Determines whether the current timestamp is the same as the specified timestamp.

Declaration
public bool Equals(RumorTimestamp other)
Parameters
Type Name Description
RumorTimestamp other

The timestamp to compare.

Returns
Type Description
bool

true if both timestamps are equal; otherwise, false.

View Source

Equals(object?)

Declaration
public override bool Equals(object? other)
Parameters
Type Name Description
object other
Returns
Type Description
bool
Overrides
ValueType.Equals(object)
View Source

Format(Span<byte>)

Serializes the timestamp as a sequence of bytes.

Declaration
public void Format(Span<byte> output)
Parameters
Type Name Description
Span<byte> output

The buffer.

View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()
View Source

Increment()

Returns an incremented timestamp.

Declaration
public RumorTimestamp Increment()
Returns
Type Description
RumorTimestamp

An incremented timestamp.

View Source

Next(ref RumorTimestamp)

Generates the next timestamp and stores the modified timestamp at the specified location atomically.

Declaration
public static RumorTimestamp Next(ref RumorTimestamp location)
Parameters
Type Name Description
RumorTimestamp location

The location of the timestamp.

Returns
Type Description
RumorTimestamp

A new timestamp that is greater than previous.

Remarks

This method is thread-safe.

View Source

ToString()

Returns hexadecimal representation of this timestamp.

Declaration
public override string ToString()
Returns
Type Description
string

The hexadecimal representation of this timestamp.

Overrides
ValueType.ToString()
View Source

TryParse(ReadOnlySpan<char>, out RumorTimestamp)

Restores the timestamp from its hexadecimal representation.

Declaration
public static bool TryParse(ReadOnlySpan<char> timestamp, out RumorTimestamp result)
Parameters
Type Name Description
ReadOnlySpan<char> timestamp

The hexadecimal representation of the timestamp.

RumorTimestamp result

The parsed timestamp.

Returns
Type Description
bool

true if timestamp parsed successfully; otherwise, false.

View Source

TryParse(string?, out RumorTimestamp)

Restores the timestamp from its hexadecimal representation.

Declaration
public static bool TryParse(string? timestamp, out RumorTimestamp result)
Parameters
Type Name Description
string timestamp

The hexadecimal representation of the timestamp.

RumorTimestamp result

The parsed timestamp.

Returns
Type Description
bool

true if timestamp parsed successfully; otherwise, false.

Operators

View Source

operator ==(in RumorTimestamp, in RumorTimestamp)

Determines whether the two timestamps are equal.

Declaration
public static bool operator ==(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if both timestamps are equal; otherwise, false.

View Source

operator >(in RumorTimestamp, in RumorTimestamp)

Determines whether the first timestamp is greater than the second one.

Declaration
public static bool operator >(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if x is greater than y.

View Source

operator >=(in RumorTimestamp, in RumorTimestamp)

Determines whether the first timestamp is greater than or equal to the second one.

Declaration
public static bool operator >=(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if x is greater than or equal to y.

View Source

operator !=(in RumorTimestamp, in RumorTimestamp)

Determines whether the two timestamps are not equal.

Declaration
public static bool operator !=(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if both timestamps are not equal; otherwise, false.

View Source

operator <(in RumorTimestamp, in RumorTimestamp)

Determines whether the first timestamp is less than the second one.

Declaration
public static bool operator <(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if x is less than y.

View Source

operator <=(in RumorTimestamp, in RumorTimestamp)

Determines whether the first timestamp is less than or equal to the second one.

Declaration
public static bool operator <=(in RumorTimestamp x, in RumorTimestamp y)
Parameters
Type Name Description
RumorTimestamp x

The first timestamp to compare.

RumorTimestamp y

The second timestamp to compare.

Returns
Type Description
bool

true if x is less than or equal to y.

Explicit Interface Implementations

View Source

Size

Represents the serialized size of this value type.

Declaration
static int Size { get; }
Returns
Type Description
int

Implements

IEquatable<T>
IBinaryFormattable<TSelf>
IComparable<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾