public interface IdleStrategy
Note regarding implementor state
Some implementations are known to be stateful, please note that you cannot safely assume implementations to be stateless. Where implementations are stateful it is recommended that implementation state is padded to avoid false sharing.
Note regarding potential for TTSP(Time To Safe Point) issues
If the caller spins in a 'counted' loop, and the implementation does not include a a safepoint poll this may cause a
TTSP (Time To SafePoint) problem. If this is the case for your application you can solve it by preventing the idle
method from being inlined by using a Hotspot compiler command as a JVM argument e.g:
-XX:CompileCommand=dontinline,org.agrona.concurrent.NoOpIdleStrategy::idle
Modifier and Type | Method and Description |
---|---|
default String |
alias()
Simple name by which the strategy can be identified.
|
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.
|
void idle(int workCount)
Callers are expected to follow this pattern:
while (isRunning)
{
idleStrategy.idle(doWork());
}
workCount
- performed in last duty cycle.void idle()
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();
}
void reset()
default String alias()
Copyright © 2014-2020 Real Logic Limited. All Rights Reserved.