public interface Pauser
| Modifier and Type | Interface and Description |
|---|---|
static class |
Pauser.SleepyWarning |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
BALANCED |
static int |
MIN_PROCESSORS |
static boolean |
SLEEPY |
| Modifier and Type | Method and Description |
|---|---|
default void |
asyncPause()
Pauses "asynchronously" whereby the issuing EventHandler can
pause without blocking other handlers in the EventLoop.
|
default boolean |
asyncPausing()
Returns if this Pauser is still asynchronously pausing.
|
static TimingPauser |
balanced()
A balanced pauser which tries to be busy for short bursts but backs off when idle.
|
static TimingPauser |
balancedUpToMillis(int millis)
A balanced pauser which tries to be busy for short bursts but backs off when idle.
|
static @NotNull Pauser |
busy()
A busy pauser which never waits
|
long |
countPaused()
Returns the number of times the pauser has checked for
completion.
|
static boolean |
getBalanced() |
static boolean |
getSleepy() |
static MilliPauser |
millis(int millis)
Wait a fixed time before running again unless woken
|
static Pauser |
millis(int minMillis,
int maxMillis)
A balanced pauser which tries to be busy for short bursts but backs off when idle.
|
void |
pause()
Pauses the current thread.
|
default void |
pause(long timeout,
TimeUnit timeUnit)
use
TimingPauser.pause(long, TimeUnit) instead |
void |
reset()
Resets the pauser's internal state back (if any) to the most aggressive setting.
|
static TimingPauser |
sleepy() |
static @NotNull TimingPauser |
timedBusy() |
long |
timePaused()
Returns the paused time so far in milliseconds.
|
void |
unpause()
Try to cancel the pausing if it is pausing.
|
static Pauser |
yielding()
Yielding pauser.
|
static Pauser |
yielding(int minBusy) |
static final int MIN_PROCESSORS
static final boolean BALANCED
static final boolean SLEEPY
static boolean getBalanced()
static boolean getSleepy()
static Pauser yielding(int minBusy)
static TimingPauser sleepy()
static TimingPauser balanced()
static TimingPauser balancedUpToMillis(int millis)
millis - maximum millis (unless in debug mode)static MilliPauser millis(int millis)
millis - to wait forstatic Pauser millis(int minMillis, int maxMillis)
minMillis - starting millismaxMillis - maximum millisstatic Pauser yielding()
@NotNull static @NotNull Pauser busy()
@NotNull static @NotNull TimingPauser timedBusy()
void pause()
The actual pause time and thread scheduling impact is not specified and depends on the implementing class. For some implementations, a progressive increase of the pause time is employed, thread executions may or may not be yielded, whereas other implementations may not pause or yield at all.
Thus, depending on the implementation this could do nothing (busy spin), yield, sleep, ...
Call this if no work was done.
default void asyncPause()
The issuing EventHandler can check if it is still pausing
asynchronously by invoking asyncPausing(). Typically this is
done as depicted below:
{@codeasyncPausing()default boolean asyncPausing()
void reset()
Pausers that progressively increases the pause time are reset back to its lowest pause time.
Call this if you just did some work.
default void pause(long timeout,
TimeUnit timeUnit)
throws TimeoutException
TimingPauser.pause(long, TimeUnit) insteadTimeoutExceptionvoid unpause()
No guarantee is made as to if unpause will actually have an effect.
long timePaused()
long countPaused()
Copyright © 2021. All rights reserved.