public final class YieldingIdleStrategy extends java.lang.Object implements IdleStrategy
IdleStrategy
that will call Thread.yield()
when the work count is zero.Constructor and Description |
---|
YieldingIdleStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
idle()
Perform current idle action (e.g.
|
void |
idle(int workCount)
Perform current idle action (e.g.
|
void |
reset()
Reset the internal state in preparation for entering an idle state again.
|
java.lang.String |
toString() |
public void idle(int workCount)
IdleStrategy
Callers are expected to follow this pattern:
while (isRunning)
{
idleStrategy.idle(doWork());
}
idle
in interface IdleStrategy
workCount
- performed in last duty cycle.public void idle()
IdleStrategy
IdleStrategy.reset()
to clear internal state when idle period is over (or before it begins).
Callers are expected to follow this pattern:
while (isRunning)
{
if (!hasWork())
{
idleStrategy.reset();
while (!hasWork())
{
if (!isRunning)
{
return;
}
idleStrategy.idle();
}
}
doWork();
}
idle
in interface IdleStrategy
public void reset()
IdleStrategy
reset
in interface IdleStrategy
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.