Class PausingAwaitableNoOpRunnable
- java.lang.Object
-
- com.pervasivecode.utils.concurrent.testing.PausingAwaitableNoOpRunnable
-
- All Implemented Interfaces:
AwaitableRunnable,PausingRunnable,Runnable
public final class PausingAwaitableNoOpRunnable extends Object implements AwaitableRunnable, PausingRunnable
A simple Runnable that pauses until released, and which provides a means of waiting until it has finished executing and determining if it has already finished.- See Also:
AwaitableNoOpRunnable,PausingNoOpRunnable
-
-
Constructor Summary
Constructors Constructor Description PausingAwaitableNoOpRunnable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitTaskCompletion()Block until the task has finished running.booleanawaitTaskCompletion(long amount, TimeUnit unit)Block until the task has finished running, or until a timeout has expired.booleanequals(Object other)inthashCode()booleanhasPaused()Has the PausingRunnable paused yet? If it has been unpaused this will also return true.booleanhasTaskFinished()Has the task finished?booleanhasUnpaused()Has the PausingRunnable been paused and then unpaused?voidrun()voidunpause()Release a paused PausingRunnable so that it can continue running.voidwaitUntilPaused()Block the current thread indefinitely, until the PausingRunnable is paused.booleanwaitUntilPaused(long amount, TimeUnit unit)Block the current thread until the PausingRunnable is paused, unless a timeout has expired while waiting.
-
-
-
Method Detail
-
hasTaskFinished
public boolean hasTaskFinished()
Description copied from interface:AwaitableRunnableHas the task finished?- Specified by:
hasTaskFinishedin interfaceAwaitableRunnable- Returns:
- True if the task has finished.
-
awaitTaskCompletion
public void awaitTaskCompletion() throws InterruptedExceptionDescription copied from interface:AwaitableRunnableBlock until the task has finished running.- Specified by:
awaitTaskCompletionin interfaceAwaitableRunnable- Throws:
InterruptedException- If the thread was interrupted while waiting.
-
awaitTaskCompletion
public boolean awaitTaskCompletion(long amount, TimeUnit unit) throws InterruptedExceptionDescription copied from interface:AwaitableRunnableBlock until the task has finished running, or until a timeout has expired.- Specified by:
awaitTaskCompletionin interfaceAwaitableRunnable- Parameters:
amount- The duration of the timeout.unit- The units of the amount parameter.- Returns:
- True if the task completed before the timeout expired; false if it did not.
- Throws:
InterruptedException- If the thread was interrupted while waiting.
-
hasPaused
public boolean hasPaused()
Description copied from interface:PausingRunnableHas the PausingRunnable paused yet? If it has been unpaused this will also return true.- Specified by:
hasPausedin interfacePausingRunnable- Returns:
- true if it is paused, or was previously paused and has been unpaused.
-
waitUntilPaused
public void waitUntilPaused() throws InterruptedExceptionDescription copied from interface:PausingRunnableBlock the current thread indefinitely, until the PausingRunnable is paused.- Specified by:
waitUntilPausedin interfacePausingRunnable- Throws:
InterruptedException- if the thread that is waiting is interrupted.
-
waitUntilPaused
public boolean waitUntilPaused(long amount, TimeUnit unit) throws InterruptedExceptionDescription copied from interface:PausingRunnableBlock the current thread until the PausingRunnable is paused, unless a timeout has expired while waiting. If the timeout expires, this method will return false.- Specified by:
waitUntilPausedin interfacePausingRunnable- Parameters:
amount- The magnitude of the timeout value.unit- The units of the timeout value.- Returns:
- true if the PausingRunnable paused before the timeout expired, or false if the timeout expired before the PausingRunnable paused.
- Throws:
InterruptedException- if the thread that is waiting is interrupted.
-
unpause
public void unpause()
Description copied from interface:PausingRunnableRelease a paused PausingRunnable so that it can continue running.- Specified by:
unpausein interfacePausingRunnable
-
hasUnpaused
public boolean hasUnpaused()
Description copied from interface:PausingRunnableHas the PausingRunnable been paused and then unpaused?- Specified by:
hasUnpausedin interfacePausingRunnable- Returns:
- true if it has been unpaused.
-
-