Package org.jvnet.hk2.config
Class WorkManager
- java.lang.Object
-
- org.jvnet.hk2.config.WorkManager
-
- All Implemented Interfaces:
Executor
public class WorkManager extends Object implements Executor
Simple helper for managing work sent to a foreign executor service. Has similarities to Fork and Join. The implementation is designed such that Tasks-1 are sent to the executor service for possibly another thread to handle. The last task is executed by the caller thread so that all threads are attempted to be fully utilized for processing including the caller's thread.- Author:
- Jeff Trent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWorkManager.ExecutionException
-
Constructor Summary
Constructors Constructor Description WorkManager(Executor exec)WorkManager(Executor exec, int tasksToDo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitCompletion()voidawaitCompletion(long timeout, TimeUnit unit)protected voidcompleted(org.jvnet.hk2.config.WorkManager.Watcher<?> watcher, Exception e)voidexecute(Runnable task)voidexecuteAll(Collection<Runnable> tasks)intgetWorkInProgressCount()<V> Future<V>submit(Callable<V> task)<V> Collection<Future<V>>submitAll(Collection<Callable<V>> tasks)
-
-
-
Method Detail
-
getWorkInProgressCount
public int getWorkInProgressCount()
-
awaitCompletion
public void awaitCompletion()
-
awaitCompletion
public void awaitCompletion(long timeout, TimeUnit unit) throws TimeoutException- Throws:
TimeoutException
-
completed
protected void completed(org.jvnet.hk2.config.WorkManager.Watcher<?> watcher, Exception e)
-
submitAll
public <V> Collection<Future<V>> submitAll(Collection<Callable<V>> tasks)
-
executeAll
public void executeAll(Collection<Runnable> tasks)
-
-