Package org.multiverse.utils
Class Bugshaker
java.lang.Object
org.multiverse.utils.Bugshaker
- All Implemented Interfaces:
MultiverseConstants
Contains some utility functions for shaking out bugs. It can be used by adding this method is the code like
this:
if(MultiverseConstants.SHAKE_BUGS){shakeBugs();}Since the SHAKE_BUGS field is final, it can be removed by the JIT is the bugshaking is disabled so there is no overhead. At the moment the inside of the Bugshaker is not configurable (so no control on how much delay and how often it happens).
-
Field Summary
Fields inherited from interface org.multiverse.MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Bugshaker
private Bugshaker()
-
-
Method Details
-
shakeBugs
public static void shakeBugs()Delays a random amount of time. What essentially happens is that a random number is selected and one in the n cases, a sleep is done and one in the n cases a yield is done. -
sleepUs
public static void sleepUs(long delayUs) Delays a number of microseconds. Having a delay smaller than a microsecond doesn't provide value since the minimum delay is a few microseconds. If the delay is smaller than 0, the call is ignored.- Parameters:
delayUs
- the number of microseconds to delay.
-