Package org.threadly.concurrent
Class AbstractSubmitterScheduler
- java.lang.Object
-
- org.threadly.concurrent.AbstractSubmitterExecutor
-
- org.threadly.concurrent.AbstractSubmitterScheduler
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,SubmitterExecutor
,SubmitterScheduler
- Direct Known Subclasses:
AbstractPriorityScheduler
,PriorityDelegatingScheduler
,ScheduledExecutorServiceWrapper
,SchedulerExecutorDelegator
,SubmitterSchedulerQueueLimitRejector
,ThreadRenamingPriorityScheduler
,ThreadRenamingSubmitterScheduler
public abstract class AbstractSubmitterScheduler extends AbstractSubmitterExecutor implements SubmitterScheduler
Similar to theAbstractSubmitterExecutor
this abstract class is designed to reduce code duplication for the multiple schedule functions. This includes error checking, as well as wrapping things up inListenableFutureTask
's if necessary. In general this wont be useful outside of Threadly developers, but must be a public interface since it is used in sub-packages.If you do find yourself using this class, please post an issue on github to tell us why. If there is something you want our schedulers to provide, we are happy to hear about it.
- Since:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description AbstractSubmitterScheduler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
schedule(java.lang.Runnable task, long delayInMs)
Schedule a one time task with a given delay.<T> ListenableFuture<T>
submitScheduled(java.lang.Runnable task, T result, long delayInMs)
Schedule a task with a given delay.<T> ListenableFuture<T>
submitScheduled(java.util.concurrent.Callable<T> task, long delayInMs)
Schedule aCallable
with a given delay.-
Methods inherited from class org.threadly.concurrent.AbstractSubmitterExecutor
execute, submit, submit
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.threadly.concurrent.SubmitterExecutor
submit, submit, submit
-
Methods inherited from interface org.threadly.concurrent.SubmitterScheduler
scheduleAtFixedRate, scheduleWithFixedDelay, submitScheduled
-
-
-
-
Method Detail
-
schedule
public void schedule(java.lang.Runnable task, long delayInMs)
Description copied from interface:SubmitterScheduler
Schedule a one time task with a given delay.- Specified by:
schedule
in interfaceSubmitterScheduler
- Parameters:
task
- runnable to executedelayInMs
- time in milliseconds to wait to execute task
-
submitScheduled
public <T> ListenableFuture<T> submitScheduled(java.lang.Runnable task, T result, long delayInMs)
Description copied from interface:SubmitterScheduler
Schedule a task with a given delay. TheFuture.get()
method will return the provided result once the runnable has completed.- Specified by:
submitScheduled
in interfaceSubmitterScheduler
- Type Parameters:
T
- type of result returned from the future- Parameters:
task
- runnable to executeresult
- result to be returned from resulting future .get() when runnable completesdelayInMs
- time in milliseconds to wait to execute task- Returns:
- a future to know when the task has completed
-
submitScheduled
public <T> ListenableFuture<T> submitScheduled(java.util.concurrent.Callable<T> task, long delayInMs)
Description copied from interface:SubmitterScheduler
Schedule aCallable
with a given delay. This is needed when a result needs to be consumed from the callable.- Specified by:
submitScheduled
in interfaceSubmitterScheduler
- Type Parameters:
T
- type of result returned from the future- Parameters:
task
- callable to be executeddelayInMs
- time in milliseconds to wait to execute task- Returns:
- a future to know when the task has completed and get the result of the callable
-
-