public class TimeoutPauser extends Object implements Pauser, TimingPauser
Pauser.SleepyWarningBALANCED, MIN_PROCESSORS, SLEEPY| Constructor and Description |
|---|
TimeoutPauser(int minBusy)
first it will busy wait, then it will yield.
|
| Modifier and Type | Method and Description |
|---|---|
long |
countPaused()
Returns the number of times the pauser has checked for
completion.
|
void |
pause()
Pauses the current thread.
|
void |
pause(long timeout,
@NotNull TimeUnit timeUnit)
use
TimingPauser.pause(long, TimeUnit) instead |
void |
reset()
Resets the pauser's internal state back (if any) to the most aggressive setting.
|
long |
timePaused()
Returns the paused time so far in milliseconds.
|
void |
unpause()
Try to cancel the pausing if it is pausing.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasyncPause, asyncPausing, balanced, balancedUpToMillis, busy, getBalanced, getSleepy, millis, millis, sleepy, timedBusy, yielding, yieldingpublic TimeoutPauser(int minBusy)
minBusy - the min number of times it will go around doing nothing, after this is reached it will then start to yieldpublic void reset()
PauserPausers that progressively increases the pause time are reset back to its lowest pause time.
Call this if you just did some work.
public void pause()
PauserThe 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.
public void pause(long timeout,
@NotNull
@NotNull TimeUnit timeUnit)
throws TimeoutException
PauserTimingPauser.pause(long, TimeUnit) insteadpause in interface Pauserpause in interface TimingPausertimeout - timeouttimeUnit - unitTimeoutException - thrown if timeout passespublic void unpause()
PauserNo guarantee is made as to if unpause will actually have an effect.
public long timePaused()
PausertimePaused in interface Pauserpublic long countPaused()
PausercountPaused in interface PauserCopyright © 2021. All rights reserved.