public final class SleeperImplementation extends Object implements Sleeper
Several threads can safely use the same Sleeper.
Sleeper.ShutdownException| Constructor and Description |
|---|
SleeperImplementation(TimeAuthority timeAuthority,
org.slf4j.Logger logger,
double factor,
double limit9975Factor)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getTimeInMilliseconds()
Return the current time in milliseconds.
|
void |
shutdown()
Shutdown this
Sleeper. |
static void |
shutdownAllCurrentSleepers()
Shutdown all Sleepers that are currently constructed.
|
void |
sleepFlat(long maximumTime)
Sleep for a time based on the maximumTime parameter.
|
void |
sleepNormal(long meanTime)
Sleep for a time based on the meanTime parameter.
|
void |
sleepNormal(long meanTime,
long sigma)
Sleep for a random time drawn from a pseudo normal distribution.
|
public SleeperImplementation(TimeAuthority timeAuthority, org.slf4j.Logger logger, double factor, double limit9975Factor)
timeAuthority - An authority on the current time.logger - A logger to chat to. Pass null for no chat.factor - All sleep times are modified by this factor.limit9975Factor - See sleepNormal(long).public static void shutdownAllCurrentSleepers()
public void shutdown()
Sleeper. Once called, all sleep method
invocations will throw Sleeper.ShutdownException,
including those already sleeping.public long getTimeInMilliseconds()
This is an abstraction over System.currentTimeMillis() and the J2SE
5 System.nanoTime() method.
getTimeInMilliseconds in interface TimeAuthoritySystem.nanoTime().public void sleepNormal(long meanTime)
throws Sleeper.ShutdownException
sleepNormal in interface SleepermeanTime - Mean time.Sleeper.ShutdownException - If this Sleeper has been shutdown.public void sleepNormal(long meanTime,
long sigma)
throws Sleeper.ShutdownException
sleepNormal in interface SleepermeanTime - Mean time.sigma - Standard deviation.Sleeper.ShutdownException - If this Sleeper has been shutdown.public void sleepFlat(long maximumTime)
throws Sleeper.ShutdownException
sleepFlat in interface SleepermaximumTime - Maximum time.Sleeper.ShutdownException - If this Sleeper has been shutdown.Copyright © 2000-2014. All Rights Reserved.