Class AwaitableExecutorService
- java.lang.Object
 - 
- com.google.common.collect.ForwardingObject
 - 
- com.google.common.util.concurrent.ForwardingExecutorService
 - 
- org.opendaylight.infrautils.testutils.concurrent.AwaitableExecutorService
 
 
 
 
- 
- All Implemented Interfaces:
 Executor,ExecutorService
public class AwaitableExecutorService extends com.google.common.util.concurrent.ForwardingExecutorServiceExecutable service wrapper allowing callers to await completion. 
- 
- 
Constructor Summary
Constructors Constructor Description AwaitableExecutorService(ExecutorService delegate)Create a new wrapper for the givenExecutorService, adding the ability to wait for job completion. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitCompletion(long timeout, TimeUnit unit)Wait for completion: this method will wait until all submitted jobs have completed, subject to the provided timeout.protected ExecutorServicedelegate()voidexecute(Runnable command)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)<T> TinvokeAny(Collection<? extends Callable<T>> tasks)<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)booleanisCompleted()Indicates whether all submitted jobs have completed.Future<?>submit(Runnable task)<T> Future<T>submit(Runnable task, T result)<T> Future<T>submit(Callable<T> task) 
 - 
 
- 
- 
Constructor Detail
- 
AwaitableExecutorService
public AwaitableExecutorService(ExecutorService delegate)
Create a new wrapper for the givenExecutorService, adding the ability to wait for job completion.- Parameters:
 delegate- The executor service to wrap.
 
 - 
 
- 
Method Detail
- 
delegate
protected ExecutorService delegate()
- Specified by:
 delegatein classcom.google.common.util.concurrent.ForwardingExecutorService
 
- 
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
 submitin interfaceExecutorService- Overrides:
 submitin classcom.google.common.util.concurrent.ForwardingExecutorService
 
- 
submit
public <T> Future<T> submit(Runnable task, T result)
- Specified by:
 submitin interfaceExecutorService- Overrides:
 submitin classcom.google.common.util.concurrent.ForwardingExecutorService
 
- 
submit
public Future<?> submit(Runnable task)
- Specified by:
 submitin interfaceExecutorService- Overrides:
 submitin classcom.google.common.util.concurrent.ForwardingExecutorService
 
- 
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
- Specified by:
 invokeAllin interfaceExecutorService- Overrides:
 invokeAllin classcom.google.common.util.concurrent.ForwardingExecutorService- Throws:
 InterruptedException
 
- 
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
 invokeAllin interfaceExecutorService- Overrides:
 invokeAllin classcom.google.common.util.concurrent.ForwardingExecutorService- Throws:
 InterruptedException
 
- 
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
- Specified by:
 invokeAnyin interfaceExecutorService- Overrides:
 invokeAnyin classcom.google.common.util.concurrent.ForwardingExecutorService- Throws:
 InterruptedExceptionExecutionException
 
- 
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
 invokeAnyin interfaceExecutorService- Overrides:
 invokeAnyin classcom.google.common.util.concurrent.ForwardingExecutorService- Throws:
 InterruptedExceptionExecutionExceptionTimeoutException
 
- 
execute
public void execute(Runnable command)
 
- 
awaitCompletion
public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedExceptionWait for completion: this method will wait until all submitted jobs have completed, subject to the provided timeout. This is inherently racy if external job submission is continuing; if the submitted jobs themselves submit new jobs, this will wait for those newly-submitted jobs to complete too.- Parameters:
 timeout- The maximum time to wait.unit- The unit used for the timeout.- Returns:
 trueif the submitted jobs have completed,falseif they haven’t.- Throws:
 InterruptedException
 
- 
isCompleted
public boolean isCompleted()
Indicates whether all submitted jobs have completed.- Returns:
 trueif all submitted jobs have completed,falseotherwise.
 
 - 
 
 -