com.twitter.common.util
Interface Clock

All Known Implementing Classes:
FakeClock

public interface Clock

An abstraction of the system clock.


Field Summary
static Clock SYSTEM_CLOCK
          A clock that returns the the actual time reported by the system.
 
Method Summary
 long nowMillis()
          Returns the current time in milliseconds since the epoch.
 long nowNanos()
          Returns the current time in nanoseconds.
 void waitFor(long millis)
          Waits for the given amount of time to pass on this clock before returning.
 

Field Detail

SYSTEM_CLOCK

static final Clock SYSTEM_CLOCK
A clock that returns the the actual time reported by the system.

Method Detail

nowMillis

long nowMillis()
Returns the current time in milliseconds since the epoch.

Returns:
The current time in milliseconds since the epoch.
See Also:
System.currentTimeMillis()

nowNanos

long nowNanos()
Returns the current time in nanoseconds. Should be used only for relative timing. System.nanoTime() for tips on using the value returned here.

Returns:
A measure of the current time in nanoseconds.

waitFor

void waitFor(long millis)
             throws InterruptedException
Waits for the given amount of time to pass on this clock before returning.

Parameters:
millis - the amount of time to wait in milliseconds
Throws:
InterruptedException - if this wait was interrupted