Lamport Clock
class LamportClock<LamportTimestamp : Comparable<LamportTimestamp>>(initialTime: LamportTimestamp, increment: (LamportTimestamp) -> LamportTimestamp, onNewTime: suspend (LamportTimestamp) -> Unit = {}) : LogicalClock<LamportTimestamp>
A generic Lamport clock.
A Lamport clock is a simple logical clock that can be used to provide a causal ordering of events. Its potential disadvantage is that it may order concurrent events in a way that is undesirable for a given application.
This implementation is thread-safe.
Constructors
Link copied to clipboard
constructor(initialTime: LamportTimestamp, increment: (LamportTimestamp) -> LamportTimestamp, onNewTime: suspend (LamportTimestamp) -> Unit = {})
Functions
Link copied to clipboard
Returns a logical timestamp that is greater than the current logical timestamp of this clock and updates the clock's internal state accordingly.
Link copied to clipboard
Updates the internal state of the clock to reflect the occurrence of an external event with the given logical timestamp.