org.LatencyUtils
Class TimeServices

java.lang.Object
  extended by org.LatencyUtils.TimeServices

public class TimeServices
extends java.lang.Object

Provide an API for time-related service, such as getting the current time and waiting for a given period of time. By default, these services are provided by actual time services in the JDK (i.e. System.nanoTime(), System.currentTimeMillis(), Thread.sleep(), and java.util.concurrent.locks.LockSupport.parkNanos()). However, if the property LatencyUtils.useActualTime is set to "false", TimeServers will only move the notion of time in response to calls to the #setCurrentTime() method.


Nested Class Summary
static class TimeServices.ScheduledExecutor
           
 
Field Summary
static boolean useActualTime
           
 
Constructor Summary
TimeServices()
           
 
Method Summary
static long currentTimeMillis()
           
static void moveTimeForward(long timeDeltaNsec)
           
static void moveTimeForwardMsec(long timeDeltaMsec)
           
static long nanoTime()
           
static void setCurrentTime(long newCurrentTime)
           
static void sleepMsecs(long sleepTimeMsec)
           
static void sleepNanos(long sleepTimeNsec)
           
static void waitUntilTime(long timeToWakeAt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useActualTime

public static final boolean useActualTime
Constructor Detail

TimeServices

public TimeServices()
Method Detail

nanoTime

public static long nanoTime()

currentTimeMillis

public static long currentTimeMillis()

sleepMsecs

public static void sleepMsecs(long sleepTimeMsec)

sleepNanos

public static void sleepNanos(long sleepTimeNsec)

waitUntilTime

public static void waitUntilTime(long timeToWakeAt)
                          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

moveTimeForward

public static void moveTimeForward(long timeDeltaNsec)
                            throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

moveTimeForwardMsec

public static void moveTimeForwardMsec(long timeDeltaMsec)
                                throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

setCurrentTime

public static void setCurrentTime(long newCurrentTime)
                           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException