org.skife.clocked
Class ClockedExecutorService
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.skife.clocked.ClockedExecutorService
- All Implemented Interfaces:
- Closeable, Executor, ExecutorService, ScheduledExecutorService
public class ClockedExecutorService
- extends ThreadPoolExecutor
- implements ScheduledExecutorService, Closeable
NOT INTENDED FOR USE OUTSIDE CAREFULLY CONTROLLED TESTS
ScheduledExecutorService implementation designed for deterministic testing. It runs off an
internal clock which must be manually advanced via the advance(long, java.util.concurrent.TimeUnit)
method.
Additionally, for recurring scheduled tasks, there is a guarantee that the task will nly
be called once for each call to advance(...)
. This is important to note as it
rather violates the normal contracts, but is very useful for testing.
Method Summary |
Future<?> |
advance(long time,
TimeUnit unit)
|
void |
close()
|
|
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)
|
Methods inherited from class java.util.concurrent.ThreadPoolExecutor |
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated |
Methods inherited from interface java.util.concurrent.ExecutorService |
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit |
ClockedExecutorService
public ClockedExecutorService(int corePoolSize)
ClockedExecutorService
public ClockedExecutorService()
advance
public Future<?> advance(long time,
TimeUnit unit)
throws ExecutionException,
InterruptedException
- Throws:
ExecutionException
InterruptedException
schedule
public ScheduledFuture<?> schedule(Runnable command,
long delay,
TimeUnit unit)
- Specified by:
schedule
in interface ScheduledExecutorService
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
long delay,
TimeUnit unit)
- Specified by:
schedule
in interface ScheduledExecutorService
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit)
- Specified by:
scheduleAtFixedRate
in interface ScheduledExecutorService
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
- Specified by:
scheduleWithFixedDelay
in interface ScheduledExecutorService
close
public void close()
- Specified by:
close
in interface Closeable
Copyright © 2014. All rights reserved.