|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlGovernor
public final class UtlGovernor
A convenience class for executing a number of operations at a maximum target rate.
This class IS supported for use by end users.
Constructor Summary | |
---|---|
UtlGovernor(int rate)
Creates a governer that will busy spin on calls to blockToNext()
if the number of prior calls has exceeded the provided rate since the
creation of the UtlGoverner. |
Method Summary | |
---|---|
void |
blockToNext()
Blocks until returning won't exceed this governer's target rate. |
static void |
run(int iterations,
int rate,
Runnable command)
Runs the provided Runnable command for a given number of iterations, attempting
to operate at the overall given rate. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UtlGovernor(int rate)
blockToNext()
if the number of prior calls has exceeded the provided rate since the
creation of the UtlGoverner.
rate
- The target rate beyond which call to blockToNext()
will block.Method Detail |
---|
public final void blockToNext()
public static final void run(int iterations, int rate, Runnable command)
Runnable
command for a given number of iterations, attempting
to operate at the overall given rate.
iterations
- The number of interations to execute.rate
- The target rate at which to run the command.command
- The command to run on each iteration.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |