public class YieldingPauser extends Object implements TimingPauser
Pauser.SleepyWarningBALANCED, MIN_BUSY, MIN_PROCESSORS, SLEEPY| Constructor and Description |
|---|
YieldingPauser(int minBusy)
Constructs a
YieldingPauser with a specified threshold for busy waiting. |
| Modifier and Type | Method and Description |
|---|---|
long |
countPaused()
Returns the number of times this pauser has been activated, including both busy-wait and yield iterations.
|
void |
pause()
Pauses the thread by either busy-waiting or yielding, depending on the number of iterations specified by
minBusy. |
void |
pause(long timeout,
@NotNull TimeUnit timeUnit)
Pauses the thread with a timeout.
|
void |
reset()
Resets the pauser's internal state back (if any) to the most aggressive setting.
|
long |
timePaused()
Returns the total time this pauser has spent yielding, measured in milliseconds.
|
String |
toString()
Provides a string representation of this pauser, which varies based on the
minBusy configuration. |
void |
unpause()
Try to cancel the pausing if it is pausing.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitasyncPause, asyncPausing, balanced, balancedUpToMillis, busy, getBalanced, getSleepy, isBusy, millis, millis, sleepy, timedBusy, yielding, yieldingpublic YieldingPauser(int minBusy)
YieldingPauser with a specified threshold for busy waiting.minBusy - the minimum number of iterations to perform busy waiting before yieldingpublic 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()
minBusy.
Initially, it will busy-wait up to minBusy iterations; thereafter, it will yield to other threads.public void pause(long timeout,
@NotNull
@NotNull TimeUnit timeUnit)
throws TimeoutException
pause in interface Pauserpause in interface TimingPausertimeout - the maximum time to wait before throwing a TimeoutExceptiontimeUnit - the unit of time for the timeout argumentTimeoutException - if the pause operation exceeds the specified timeoutpublic void unpause()
PauserNo guarantee is made that this call will actually have an effect.
public long timePaused()
timePaused in interface Pauserpublic long countPaused()
countPaused in interface PauserCopyright © 2024. All rights reserved.