|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.threads.FutureTaskManager
public class FutureTaskManager
A FutureTaskManager will manage the Futures created e.g. by a
ExecutorService.submit(java.util.concurrent.Callable) call and allows to wait on all managed Futures.
If an ExecutorService instance is declared using FutureTaskManager(ExecutorService), it is possible to let the
FutureTaskManager submit tasks by invoking submitAndManage(Callable) or submitAndManage(Runnable).
| Field Summary | |
|---|---|
protected ExecutorService |
executorService
|
protected List<Future<?>> |
futureList
|
| Constructor Summary | |
|---|---|
FutureTaskManager()
Does not support submitAndManage(Callable) and submitAndManage(Runnable). |
|
FutureTaskManager(ExecutorService executorService)
|
|
| Method Summary | ||
|---|---|---|
boolean |
areAllTasksFinished()
Returns true if all given Future task return true for Future.isDone() |
|
void |
clearFinishedTasks()
Clears all Futures which are Future.isDone() |
|
List<Future<?>> |
getFutureList()
Returns the List of manage Futures |
|
boolean |
hasExecutorService()
Returns true if this FutureTaskManager has an ExecutorService available |
|
void |
manageFutureTask(Future<?> future)
Manages the given Future |
|
void |
manageFutureTask(Iterable<Future<?>> futureIterable)
Manages the given Future instances |
|
void |
submitAndManage(Callable<?> callable)
Submits the given Callable to the internal ExecutorService. |
|
void |
submitAndManage(Callable<?> callable,
int submitCount)
Similar to submitAndManage(Callable) but the Callable will be submitted the given number times |
|
void |
submitAndManage(ExecutorService executorService,
Callable<?> callable)
Submits the given Callable to the given ExecutorService instance and calls manageFutureTask(Future)
for the resulting FutureTask |
|
void |
submitAndManage(ExecutorService executorService,
Callable<?> callable,
int submitCount)
|
|
void |
submitAndManage(ExecutorService executorService,
Runnable runnable)
Submits the given Runnable to the given ExecutorService instance and calls manageFutureTask(Future)
for the resulting FutureTask |
|
void |
submitAndManage(ExecutorService executorService,
Runnable runnable,
int submitCount)
|
|
void |
submitAndManage(Runnable runnable)
|
|
void |
submitAndManage(Runnable runnable,
int submitCount)
Similar to submitAndManage(Callable, int) but for Runnable |
|
void |
submitAndManageCallables(ExecutorService executorService,
Collection<? extends Callable<?>> callableCollection,
int submitCount)
|
|
void |
submitAndManageRunnables(ExecutorService executorService,
Collection<Runnable> runnableCollection,
int submitCount)
|
|
|
waitForAllTasksToFinish()
Uses the Future.get() to wait on all managed Futures until they are finished |
|
static
|
waitForTaskToFinish(Future<V> future)
Waits for a given Future to finish. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final List<Future<?>> futureList
protected final ExecutorService executorService
| Constructor Detail |
|---|
public FutureTaskManager(ExecutorService executorService)
executorService - FutureTaskManagerpublic FutureTaskManager()
submitAndManage(Callable) and submitAndManage(Runnable). If these methods should be used
provide an ExecutorService instance using FutureTaskManager(ExecutorService)
FutureTaskManager| Method Detail |
|---|
public void manageFutureTask(Future<?> future)
Future
future - public void manageFutureTask(Iterable<Future<?>> futureIterable)
Future instances
futureIterable -
public void submitAndManage(ExecutorService executorService,
Callable<?> callable)
Callable to the given ExecutorService instance and calls manageFutureTask(Future)
for the resulting FutureTask
executorService - callable -
public void submitAndManage(ExecutorService executorService,
Runnable runnable)
Runnable to the given ExecutorService instance and calls manageFutureTask(Future)
for the resulting FutureTask
executorService - runnable - public void submitAndManage(Callable<?> callable)
Callable to the internal ExecutorService. Throws an UnsupportedOperationException
if not ExecutorService instance is available.
callable - Callable
public void submitAndManage(Callable<?> callable,
int submitCount)
submitAndManage(Callable) but the Callable will be submitted the given number times
callable - submitCount - public void submitAndManage(Runnable runnable)
runnable - Runnable,
submitAndManage(Callable)
public void submitAndManage(Runnable runnable,
int submitCount)
submitAndManage(Callable, int) but for Runnable
runnable - submitCount -
public void submitAndManage(ExecutorService executorService,
Runnable runnable,
int submitCount)
executorService - runnable - submitCount - submitAndManage(Callable),
submitAndManageRunnables(ExecutorService, Collection, int)
public void submitAndManage(ExecutorService executorService,
Callable<?> callable,
int submitCount)
executorService - callable - submitCount - submitAndManage(ExecutorService, Callable),
submitAndManageCallables(ExecutorService, Collection, int)
public void submitAndManageRunnables(ExecutorService executorService,
Collection<Runnable> runnableCollection,
int submitCount)
executorService - runnableCollection - submitCount - submitAndManageCallables(ExecutorService, Collection, int)
public void submitAndManageCallables(ExecutorService executorService,
Collection<? extends Callable<?>> callableCollection,
int submitCount)
callableCollection - submitCount - submitAndManage(ExecutorService, Callable),
submitAndManage(Callable)public <V> ExceptionHandledResult<List<V>> waitForAllTasksToFinish()
Future.get() to wait on all managed Futures until they are finished
ExceptionHandledResultpublic static <V> ExceptionHandledResult<V> waitForTaskToFinish(Future<V> future)
Future to finish. Returns an ExceptionHandledResult which does exclude any
InterruptedException
future -
ExceptionHandledResultpublic void clearFinishedTasks()
Futures which are Future.isDone()
public List<Future<?>> getFutureList()
List of manage Futures
public boolean hasExecutorService()
FutureTaskManager has an ExecutorService available
public boolean areAllTasksFinished()
Future task return true for Future.isDone()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||