public class SingleThreadSchedulerServiceWrapper
extends java.lang.Object
SingleThreadScheduler
to be a drop in replacement for any
ScheduledExecutorService
(AKA the
ScheduledThreadPoolExecutor
interface). It does make some performance sacrifices to adhere to this interface, but those are
pretty minimal. The largest compromise in here is easily scheduleAtFixedRate (which you should
read the javadocs for if you need).Constructor and Description |
---|
SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler)
Constructs a new wrapper to adhere to the
ScheduledExecutorService interface. |
SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler,
TaskPriority taskPriority)
Constructs a new wrapper to adhere to the
ScheduledExecutorService interface. |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
execute(java.lang.Runnable task) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<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) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
<V> ListenableScheduledFuture<V> |
schedule(java.util.concurrent.Callable<V> callable,
long delay,
java.util.concurrent.TimeUnit unit) |
ListenableScheduledFuture<?> |
schedule(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit unit) |
ListenableScheduledFuture<?> |
scheduleAtFixedRate(java.lang.Runnable task,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit) |
ListenableScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable task,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<T> ListenableFuture<T> |
submit(java.util.concurrent.Callable<T> task) |
ListenableFuture<?> |
submit(java.lang.Runnable task) |
<T> ListenableFuture<T> |
submit(java.lang.Runnable task,
T result) |
public SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler)
ScheduledExecutorService
interface.scheduler
- scheduler implementation to rely onpublic SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler, TaskPriority taskPriority)
ScheduledExecutorService
interface.scheduler
- scheduler implementation to rely ontaskPriority
- Priority for all tasks submitted to the parent schedulerpublic void shutdown()
public java.util.List<java.lang.Runnable> shutdownNow()
public boolean isTerminated()
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean isShutdown()
isShutdown
in interface java.util.concurrent.ExecutorService
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
submit
in interface java.util.concurrent.ExecutorService
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
submit
in interface java.util.concurrent.ExecutorService
public ListenableFuture<?> submit(java.lang.Runnable task)
submit
in interface java.util.concurrent.ExecutorService
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.ExecutorService
java.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.ExecutorService
java.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.ExecutorService
java.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.ExecutorService
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
public ListenableScheduledFuture<?> schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
schedule
in interface java.util.concurrent.ScheduledExecutorService
public <V> ListenableScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
schedule
in interface java.util.concurrent.ScheduledExecutorService
public ListenableScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
scheduleWithFixedDelay
in interface java.util.concurrent.ScheduledExecutorService
public ListenableScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
scheduleAtFixedRate
in interface java.util.concurrent.ScheduledExecutorService