|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.api.clock.StrictPrimitiveClock
public final class StrictPrimitiveClock
The intuitive implementation of a PrimitiveClock. It wraps an AtomicLong and increases the value every
time a tick is done.
RelaxedPrimitiveClock for more info.
A StrictPrimitiveClock is thread-safe.
Reading the version is very cheap (even though a volatile read needs to be executed).
| Constructor Summary | |
|---|---|
StrictPrimitiveClock()
Creates a new StrictPrimitiveClock. |
|
StrictPrimitiveClock(long time)
Creates a new StrictPrimitiveClock initialized with the provided time. |
|
| Method Summary | |
|---|---|
long |
getVersion()
Returns the current version of this PrimitiveClock. |
long |
strictTick()
Executes a strict clock tick by increasing the version. |
long |
tick()
Executes a clock tick by increasing the version. |
long |
tickTo(long version)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public StrictPrimitiveClock()
public StrictPrimitiveClock(long time)
time - the initial time of the clock
IllegalArgumentException - if time smaller than 0.| Method Detail |
|---|
public long strictTick()
PrimitiveClockPrimitiveClock.tick() is that the former will always increase the version for every calling thread and the
is allowed to return the same version for concurrent ticks.
The returned value could be stale as soon as it is received.
strictTick in interface PrimitiveClockPrimitiveClock.tick()public long tick()
PrimitiveClockPrimitiveClock.getVersion() method will always return a time equal
or larger than.the last tick.
The returned value could be stale as soon as it is received.
tick in interface PrimitiveClockPrimitiveClock.strictTick()public long tickTo(long version)
tickTo in interface PrimitiveClockpublic long getVersion()
PrimitiveClock
getVersion in interface PrimitiveClockpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||