Struct RumorTimestamp
Represents Lamport timestamp of the rumor mixed with the timestamp returned by the local clock.
Implements
Inherited Members
Namespace: DotNext.Net.Cluster.Messaging.Gossip
Assembly: DotNext.Net.Cluster.dll
Syntax
public readonly struct RumorTimestamp : IEquatable<RumorTimestamp>, IBinaryFormattable<RumorTimestamp>, IComparable<RumorTimestamp>
Constructors
| Edit this page View SourceRumorTimestamp()
Generates a new fresh timestamp.
Declaration
public RumorTimestamp()
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 |
Properties
| Edit this page View SourceMaxValue
Gets the maximum possible value of the timestamp.
Declaration
public static RumorTimestamp MaxValue { get; }
Property Value
Type | Description |
---|---|
RumorTimestamp |
MinValue
Gets the minimum possible value of the timestamp.
Declaration
public static RumorTimestamp MinValue { get; }
Property Value
Type | Description |
---|---|
RumorTimestamp |
Size
Represents the serialized size of this value type.
Declaration
public static int Size { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCompareTo(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. |
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 |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object? other)
Parameters
Type | Name | Description |
---|---|---|
object | other |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
| Edit this page View SourceFormat(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. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
| Edit this page View SourceIncrement()
Returns an incremented timestamp.
Declaration
public RumorTimestamp Increment()
Returns
Type | Description |
---|---|
RumorTimestamp | An incremented timestamp. |
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.
ToString()
Returns hexadecimal representation of this timestamp.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The hexadecimal representation of this timestamp. |
Overrides
| Edit this page View SourceTryParse(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 |
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 |
Operators
| Edit this page View Sourceoperator ==(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 |
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 |
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 |
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 |
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 |
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 |