|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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 Executors or ExecutorServices 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<Callable<T>> tasks)
|
|
|
invokeAll(Collection<Callable<T>> tasks,
long timeout,
TimeUnit unit)
|
|
|
invokeAny(Collection<Callable<T>> tasks)
|
|
|
invokeAny(Collection<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 ExecutorServiceInterruptedException
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)
throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
long timeout,
TimeUnit unit)
throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException
public <T> T invokeAny(Collection<Callable<T>> tasks)
throws InterruptedException,
ExecutionException
invokeAny in interface ExecutorServiceInterruptedException
ExecutionException
public <T> T invokeAny(Collection<Callable<T>> tasks,
long timeout,
TimeUnit unit)
throws InterruptedException,
ExecutionException,
TimeoutException
invokeAny in interface ExecutorServiceInterruptedException
ExecutionException
TimeoutExceptionpublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic <T> Future<T> submit(Callable<T> callable)
submit in interface ExecutorServicepublic 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 | ||||||||