|
|||||||||
| 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,
java.util.concurrent.TimeUnit unit)
|
|
void |
execute(java.lang.Runnable command)
|
|
|
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
|
|
|
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
|
|
|
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
|
|
|
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.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(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit)
|
|
java.util.concurrent.ScheduledFuture<?> |
schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
|
|
java.util.concurrent.ScheduledFuture<?> |
scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
|
|
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
|
|
void |
shutdown()
|
|
java.util.List<java.lang.Runnable> |
shutdownNow()
|
|
|
submit(java.util.concurrent.Callable<T> callable)
|
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable command)
|
|
|
submit(java.lang.Runnable command,
T result)
|
|
void |
tick(long duration,
java.util.concurrent.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,
java.util.concurrent.TimeUnit timeUnit)
duration - timeUnit - public void runUntilIdle()
public void runNextPendingCommand()
public boolean isIdle()
public void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executor
public java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
schedule in interface java.util.concurrent.ScheduledExecutorService
public <V> java.util.concurrent.ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit)
schedule in interface java.util.concurrent.ScheduledExecutorService
public java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
scheduleAtFixedRate in interface java.util.concurrent.ScheduledExecutorService
public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
scheduleWithFixedDelay in interface java.util.concurrent.ScheduledExecutorService
public boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedException
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedException
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedException
java.util.concurrent.ExecutionException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutExceptionpublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> callable)
submit in interface java.util.concurrent.ExecutorServicepublic java.util.concurrent.Future<?> submit(java.lang.Runnable command)
submit in interface java.util.concurrent.ExecutorService
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable command,
T result)
submit in interface java.util.concurrent.ExecutorService
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||