Class PrioritySchedulerServiceWrapper
- java.lang.Object
-
- org.threadly.concurrent.wrapper.compatibility.PrioritySchedulerServiceWrapper
-
- All Implemented Interfaces:
java.util.concurrent.Executor,java.util.concurrent.ExecutorService,java.util.concurrent.ScheduledExecutorService
public class PrioritySchedulerServiceWrapper extends java.lang.ObjectThis is a wrapper forPrioritySchedulerto be a drop in replacement for anyScheduledExecutorService(AKA theScheduledThreadPoolExecutorinterface). 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 1.0.0 as org.threadly.concurrent.PriorityScheduledExecutorServiceWrapper)
-
-
Constructor Summary
Constructors Constructor Description PrioritySchedulerServiceWrapper(PriorityScheduler scheduler)Constructs a new wrapper to adhere to theScheduledExecutorServiceinterface.PrioritySchedulerServiceWrapper(PriorityScheduler scheduler, TaskPriority taskPriority)Constructs a new wrapper to adhere to theScheduledExecutorServiceinterface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)voidexecute(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> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)booleanisShutdown()booleanisTerminated()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)voidshutdown()java.util.List<java.lang.Runnable>shutdownNow()This call will stop the processor as quick as possible.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
-
PrioritySchedulerServiceWrapper
public PrioritySchedulerServiceWrapper(PriorityScheduler scheduler)
Constructs a new wrapper to adhere to theScheduledExecutorServiceinterface.- Parameters:
scheduler-PrioritySchedulerimplementation to rely on
-
PrioritySchedulerServiceWrapper
public PrioritySchedulerServiceWrapper(PriorityScheduler scheduler, TaskPriority taskPriority)
Constructs a new wrapper to adhere to theScheduledExecutorServiceinterface.- Parameters:
scheduler-PrioritySchedulerimplementation 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()
This call will stop the processor as quick as possible. Any tasks which are awaiting execution will be canceled and returned as a result to this call.Unlike
ExecutorServiceimplementation there is no attempt to stop any currently execution tasks.This method does not wait for actively executing tasks toterminate. Use
awaitTerminationto do that.- Returns:
- list of tasks that never commenced execution
-
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:
isShutdownin interfacejava.util.concurrent.ExecutorService
-
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
submit
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
submit
public ListenableFuture<?> submit(java.lang.Runnable task)
- Specified by:
submitin 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:
invokeAllin 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:
invokeAllin 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:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.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:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable task)
- Specified by:
executein interfacejava.util.concurrent.Executor
-
schedule
public ListenableScheduledFuture<?> schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedulein 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:
schedulein interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleWithFixedDelay
public ListenableScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleAtFixedRate
public ListenableScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfacejava.util.concurrent.ScheduledExecutorService
-
-