Top Description Inners Fields Constructors Methods
net.sf.ehcache.util

pack-priv final Class SlewClock

extends Object
Class Inheritance
Imports
net.sf.ehcache.util.lang.VicariousThreadLocal, java.util.concurrent.atomic.AtomicLong, org.slf4j.Logger, .LoggerFactory

SlewClock will return the current time in millis, but will never go back in time. If it detects that a back movement in time, it will slew the results while keeping them incrementing until time has caught up
Authors
Chris Denis, Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
SlewClock.TimeProvider

Defines how the SlewClock utility class will get to the wall clock

Field Summary

Modifier and TypeField and Description
private static final AtomicLong
private static final long
private static final Logger
private static final VicariousThreadLocal<Long>
private static final SlewClock.TimeProvider
private static final int
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static long

Returns:

the amount of milliseconds the thread is behind the wall clock, 0 if none.
behind
()

The method will check how much behind is the current thread compared to the wall clock since the last timeMillis() call.

private static long
pack-priv static boolean

Returns:

true if the thread is being marked as catching up on time
isThreadCatchingUp
()

Verifies whether the current thread is currently catching up on time.

pack-priv static void
realignWithTimeProvider()

Deprecated
For testing purposes, you probably never want to use this.
private static long
sleepTime(final long current, final long previous)

pack-priv static long

Returns:

The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
timeMillis
()

Will return the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CURRENTback to summary
private static final AtomicLong CURRENT
DRIFT_MAXIMALback to summary
private static final long DRIFT_MAXIMAL
LOGback to summary
private static final Logger LOG
OFFSETback to summary
private static final VicariousThreadLocal<Long> OFFSET
PROVIDERback to summary
private static final SlewClock.TimeProvider PROVIDER
SLEEP_BASEback to summary
private static final int SLEEP_BASE
SLEEP_MAXIMALback to summary
private static final long SLEEP_MAXIMAL

Constructor Detail

SlewClockback to summary
private SlewClock()

Method Detail

behindback to summary
pack-priv static long behind()

The method will check how much behind is the current thread compared to the wall clock since the last timeMillis() call. To be meaning full, this method has to be called after the thread has called timeMillis() at least once

Returns:long

the amount of milliseconds the thread is behind the wall clock, 0 if none.

getCurrentTimeback to summary
private static long getCurrentTime()
isThreadCatchingUpback to summary
pack-priv static boolean isThreadCatchingUp()

Verifies whether the current thread is currently catching up on time. To be meaning full, this method has to be called after the thread has called timeMillis() at least once

Returns:boolean

true if the thread is being marked as catching up on time

realignWithTimeProviderback to summary
pack-priv static void realignWithTimeProvider()

Deprecated

For testing purposes, you probably never want to use this. This method will resync, basically resetting any on going slewing, its internal clock tracking with whatever value the provider seeds it with.

Annotations
@Deprecated
sleepTimeback to summary
private static long sleepTime(final long current, final long previous)
timeMillisback to summary
pack-priv static long timeMillis()

Will return the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. But without ever going back. If a movement back in time is detected, the method will slew until time caught up

Returns:long

The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

net.sf.ehcache.util back to summary

pack-priv Interface SlewClock.TimeProvider


Defines how the SlewClock utility class will get to the wall clock

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
currentTimeMillis
()

Method Detail

currentTimeMillisback to summary
public long currentTimeMillis()
Returns:long

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.