Package org.threadly.concurrent
Class AbstractSubmitterExecutor
- java.lang.Object
-
- org.threadly.concurrent.AbstractSubmitterExecutor
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,SubmitterExecutor
- Direct Known Subclasses:
AbstractSubmitterScheduler
,ExecutorQueueLimitRejector
,ExecutorStatisticWrapper
,SubmitterExecutorAdapter
,ThreadRenamingExecutor
,UnfairExecutor
public abstract class AbstractSubmitterExecutor extends java.lang.Object implements SubmitterExecutor
Since the conversion to aSubmitterExecutor
from an executor is often the same (just using theListenableFutureTask
to wrap the task). This class provides an easy way to create aSubmitterExecutor
. Take a look atSubmitterExecutorAdapter
for an easy example of how this is used. In general this wont be useful outside of Threadly developers, but must be a public visibility 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:
- 1.3.0
-
-
Constructor Summary
Constructors Constructor Description AbstractSubmitterExecutor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(java.lang.Runnable task)
<T> ListenableFuture<T>
submit(java.lang.Runnable task, T result)
Submit a task to run as soon as possible.<T> ListenableFuture<T>
submit(java.util.concurrent.Callable<T> task)
Submit aCallable
to run as soon as possible.-
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
-
-
-
-
Method Detail
-
execute
public void execute(java.lang.Runnable task)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
submit
public <T> ListenableFuture<T> submit(java.lang.Runnable task, T result)
Description copied from interface:SubmitterExecutor
Submit a task to run as soon as possible. TheFuture.get()
method will return the provided result once the runnable has completed.- Specified by:
submit
in interfaceSubmitterExecutor
- Type Parameters:
T
- type of result for future- Parameters:
task
- runnable to be executedresult
- result to be returned from resulting future .get() when runnable completes- Returns:
- a future to know when the task has completed
-
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
Description copied from interface:SubmitterExecutor
Submit aCallable
to run as soon as possible. This is needed when a result needs to be consumed from the callable.- Specified by:
submit
in interfaceSubmitterExecutor
- Type Parameters:
T
- type of result returned from the future- Parameters:
task
- callable to be executed- Returns:
- a future to know when the task has completed and get the result of the callable
-
-