Class SingleThreadSchedulerServiceWrapper
- java.lang.Object
-
- org.threadly.concurrent.wrapper.compatibility.SingleThreadSchedulerServiceWrapper
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
public class SingleThreadSchedulerServiceWrapper extends java.lang.Object
This is a wrapper forSingleThreadScheduler
to be a drop in replacement for anyScheduledExecutorService
(AKA theScheduledThreadPoolExecutor
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).- Since:
- 4.6.0 (since 2.0.0 at org.threadly.concurrent)
-
-
Constructor Summary
Constructors Constructor Description SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler)
Constructs a new wrapper to adhere to theScheduledExecutorService
interface.SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler, TaskPriority taskPriority)
Constructs a new wrapper to adhere to theScheduledExecutorService
interface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
ListenableScheduledFuture<?>
schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
<V> ListenableScheduledFuture<V>
schedule(java.util.concurrent.Callable<V> callable, 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()
ListenableFuture<?>
submit(java.lang.Runnable task)
<T> ListenableFuture<T>
submit(java.lang.Runnable task, T result)
<T> ListenableFuture<T>
submit(java.util.concurrent.Callable<T> task)
-
-
-
Constructor Detail
-
SingleThreadSchedulerServiceWrapper
public SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler)
Constructs a new wrapper to adhere to theScheduledExecutorService
interface.- Parameters:
scheduler
- scheduler implementation to rely on
-
SingleThreadSchedulerServiceWrapper
public SingleThreadSchedulerServiceWrapper(SingleThreadScheduler scheduler, TaskPriority taskPriority)
Constructs a new wrapper to adhere to theScheduledExecutorService
interface.- Parameters:
scheduler
- scheduler implementation to rely ontaskPriority
- Priority for all tasks submitted to the parent scheduler
-
-
Method Detail
-
shutdown
public void shutdown()
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
-
isTerminated
public boolean isTerminated()
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public ListenableFuture<?> submit(java.lang.Runnable task)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
invokeAll
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
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAll
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
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
invokeAny
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
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable task)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
schedule
public ListenableScheduledFuture<?> schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
schedule
public <V> ListenableScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleWithFixedDelay
public ListenableScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleWithFixedDelay
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleAtFixedRate
public ListenableScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleAtFixedRate
in interfacejava.util.concurrent.ScheduledExecutorService
-
-