Package io.atomix.utils.time
Class LogicalClock
- java.lang.Object
-
- io.atomix.utils.time.LogicalClock
-
- All Implemented Interfaces:
Clock<LogicalTimestamp>
public class LogicalClock extends Object implements Clock<LogicalTimestamp>
Logical clock.
-
-
Constructor Summary
Constructors Constructor Description LogicalClock()LogicalClock(LogicalTimestamp currentTimestamp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogicalTimestampgetTime()Returns the current time of the clock.LogicalTimestampincrement()Increments the clock and returns the new timestamp.LogicalTimestampincrementAndUpdate(LogicalTimestamp timestamp)Increments the clock and updates it using the given timestamp.StringtoString()LogicalTimestampupdate(LogicalTimestamp timestamp)Updates the clock using the given timestamp.
-
-
-
Constructor Detail
-
LogicalClock
public LogicalClock()
-
LogicalClock
public LogicalClock(LogicalTimestamp currentTimestamp)
-
-
Method Detail
-
getTime
public LogicalTimestamp getTime()
Description copied from interface:ClockReturns the current time of the clock.- Specified by:
getTimein interfaceClock<LogicalTimestamp>- Returns:
- the current time
-
increment
public LogicalTimestamp increment()
Increments the clock and returns the new timestamp.- Returns:
- the updated clock time
-
update
public LogicalTimestamp update(LogicalTimestamp timestamp)
Updates the clock using the given timestamp.- Parameters:
timestamp- the timestamp with which to update the clock- Returns:
- the updated clock time
-
incrementAndUpdate
public LogicalTimestamp incrementAndUpdate(LogicalTimestamp timestamp)
Increments the clock and updates it using the given timestamp.- Parameters:
timestamp- the timestamp with which to update the clock- Returns:
- the updated clock time
-
-