-
- All Implemented Interfaces:
-
java.util.concurrent.Executor,java.util.concurrent.ExecutorService,java.util.concurrent.ScheduledExecutorService
public final class FakeScheduledExecutorService implements ScheduledExecutorService
A fake ScheduledExecutorService which gives control over when scheduled tasks are run without requiring a separate thread
-
-
Constructor Summary
Constructors Constructor Description FakeScheduledExecutorService(FakeClock clock)
-
Method Summary
Modifier and Type Method Description final FakeClockgetClock()ScheduledFuture<?>scheduleAtFixedRate(Runnable command, Long initialDelay, Long period, TimeUnit unit)ScheduledFuture<?>schedule(Runnable command, Long delay, TimeUnit unit)<V extends Any> ScheduledFuture<V>schedule(Callable<V> callable, Long delay, TimeUnit unit)ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, Long initialDelay, Long delay, TimeUnit unit)final IntegernumPendingJobs()final UnitrunOne()Run the next pending task and advance the clock to that time final UnitrunUntil(Instant endTime)Run pending tasks until endTime, or until there are no pending tasks in the queue, advancing the clock with each task. final Unitrun()Runs all jobs that are due to run by the current time. Unitexecute(Runnable command)Voidshutdown()List<Runnable>shutdownNow()BooleanisShutdown()BooleanisTerminated()BooleanawaitTermination(Long timeout, TimeUnit unit)<T extends Any> Future<T>submit(Callable<T> task)<T extends Any> Future<T>submit(Runnable task, T result)Future<?>submit(Runnable task)<T extends Any> List<Future<T>>invokeAll(Collection<out Callable<T>> tasks)<T extends Any> List<Future<T>>invokeAll(Collection<out Callable<T>> tasks, Long timeout, TimeUnit unit)<T extends Any> TinvokeAny(Collection<out Callable<T>> tasks)<T extends Any> TinvokeAny(Collection<out Callable<T>> tasks, Long timeout, TimeUnit unit)-
-
Constructor Detail
-
FakeScheduledExecutorService
FakeScheduledExecutorService(FakeClock clock)
-
-
Method Detail
-
scheduleAtFixedRate
ScheduledFuture<?> scheduleAtFixedRate(Runnable command, Long initialDelay, Long period, TimeUnit unit)
-
schedule
ScheduledFuture<?> schedule(Runnable command, Long delay, TimeUnit unit)
-
schedule
<V extends Any> ScheduledFuture<V> schedule(Callable<V> callable, Long delay, TimeUnit unit)
-
scheduleWithFixedDelay
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, Long initialDelay, Long delay, TimeUnit unit)
-
numPendingJobs
final Integer numPendingJobs()
-
runUntil
final Unit runUntil(Instant endTime)
Run pending tasks until endTime, or until there are no pending tasks in the queue, advancing the clock with each task.
-
run
final Unit run()
Runs all jobs that are due to run by the current time. This may include a single job multiple times if the time since the last run is longer than 2 times the job's period
-
shutdownNow
List<Runnable> shutdownNow()
-
isShutdown
Boolean isShutdown()
-
isTerminated
Boolean isTerminated()
-
awaitTermination
Boolean awaitTermination(Long timeout, TimeUnit unit)
-
invokeAll
<T extends Any> List<Future<T>> invokeAll(Collection<out Callable<T>> tasks, Long timeout, TimeUnit unit)
-
-
-
-