|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmock.lib.concurrent.DeterministicScheduler
public class DeterministicScheduler
A ScheduledExecutorService
that executes commands on the thread that calls
runNextPendingCommand
, runUntilIdle
or
tick
. Objects of this class can also be used
as Executor
s or ExecutorService
s if you just want to control background execution
and don't need to schedule commands, but it may be simpler to use a DeterministicExecutor
.
Constructor Summary | |
---|---|
DeterministicScheduler()
|
Method Summary | ||
---|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
|
|
void |
execute(Runnable command)
|
|
|
invokeAll(Collection<? extends Callable<T>> tasks)
|
|
|
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit)
|
|
|
invokeAny(Collection<? extends Callable<T>> tasks)
|
|
|
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit)
|
|
boolean |
isIdle()
Reports whether scheduler is "idle": has no commands pending immediate execution. |
|
boolean |
isShutdown()
|
|
boolean |
isTerminated()
|
|
void |
runNextPendingCommand()
Runs the next command scheduled to be executed immediately. |
|
void |
runUntilIdle()
Runs all commands scheduled to be executed immediately but does not tick time forward. |
|
|
schedule(Callable<V> callable,
long delay,
TimeUnit unit)
|
|
ScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit)
|
|
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit)
|
|
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
|
|
void |
shutdown()
|
|
List<Runnable> |
shutdownNow()
|
|
|
submit(Callable<T> callable)
|
|
Future<?> |
submit(Runnable command)
|
|
|
submit(Runnable command,
T result)
|
|
void |
tick(long duration,
TimeUnit timeUnit)
Runs time forwards by a given duration, executing any commands scheduled for execution during that time period, and any background tasks spawned by the scheduled tasks. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeterministicScheduler()
Method Detail |
---|
public void tick(long duration, TimeUnit timeUnit)
duration
- timeUnit
- public void runUntilIdle()
public void runNextPendingCommand()
public boolean isIdle()
public void execute(Runnable command)
execute
in interface Executor
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
schedule
in interface ScheduledExecutorService
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
schedule
in interface ScheduledExecutorService
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
scheduleAtFixedRate
in interface ScheduledExecutorService
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
scheduleWithFixedDelay
in interface ScheduledExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public <T> Future<T> submit(Callable<T> callable)
submit
in interface ExecutorService
public Future<?> submit(Runnable command)
submit
in interface ExecutorService
public <T> Future<T> submit(Runnable command, T result)
submit
in interface ExecutorService
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |