Package me.ahoo.cosid.machine
Class DefaultClockBackwardsSynchronizer
java.lang.Object
me.ahoo.cosid.machine.DefaultClockBackwardsSynchronizer
- All Implemented Interfaces:
ClockBackwardsSynchronizer
Default Clock Backwards Synchronizer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from interface me.ahoo.cosid.machine.ClockBackwardsSynchronizer
DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsync(long lastTimestamp) Synchronizes clock by waiting until current time exceeds lastTimestamp.voidsyncUninterruptibly(long lastTimestamp) Synchronizes clock without throwing InterruptedException.
-
Field Details
-
DEFAULT_SPIN_THRESHOLD
public static final int DEFAULT_SPIN_THRESHOLD- See Also:
-
DEFAULT_BROKEN_THRESHOLD
public static final int DEFAULT_BROKEN_THRESHOLD- See Also:
-
-
Constructor Details
-
DefaultClockBackwardsSynchronizer
public DefaultClockBackwardsSynchronizer() -
DefaultClockBackwardsSynchronizer
public DefaultClockBackwardsSynchronizer(int spinThreshold, int brokenThreshold)
-
-
Method Details
-
sync
Description copied from interface:ClockBackwardsSynchronizerSynchronizes clock by waiting until current time exceeds lastTimestamp.- Specified by:
syncin interfaceClockBackwardsSynchronizer- Parameters:
lastTimestamp- the last timestamp that was generated- Throws:
InterruptedException- if thread is interrupted while waitingClockTooManyBackwardsException- if clock backwards exceeds threshold
-
syncUninterruptibly
Description copied from interface:ClockBackwardsSynchronizerSynchronizes clock without throwing InterruptedException.- Specified by:
syncUninterruptiblyin interfaceClockBackwardsSynchronizer- Parameters:
lastTimestamp- the last timestamp that was generated- Throws:
ClockTooManyBackwardsException- if clock backwards exceeds threshold
-