Package com.saxonica.ee.trans
Class CountingCompletionService<V>
- java.lang.Object
-
- java.util.concurrent.ExecutorCompletionService<V>
-
- com.saxonica.ee.trans.CountingCompletionService<V>
-
- All Implemented Interfaces:
java.util.concurrent.CompletionService<V>
public class CountingCompletionService<V> extends java.util.concurrent.ExecutorCompletionService<V>
Extension of ExecutorCompletionService to count the number of tasks submitted and take that many completed tasks before calling it a day.This is necessary because the base class, ExecutorCompletionService, does not provide any way of knowing how many results you need to read off before you know that you have read them all.
-
-
Constructor Summary
Constructors Constructor Description CountingCompletionService(java.util.concurrent.Executor executor)
CountingCompletionService(java.util.concurrent.Executor executor, java.util.concurrent.BlockingQueue<java.util.concurrent.Future<V>> queue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getNumberOfCompletedTasks()
long
getNumberOfSubmittedTasks()
boolean
hasUncompletedTasks()
java.util.concurrent.Future<V>
poll()
java.util.concurrent.Future<V>
poll(long timeout, java.util.concurrent.TimeUnit unit)
java.util.concurrent.Future<V>
submit(java.lang.Runnable task, V result)
java.util.concurrent.Future<V>
submit(java.util.concurrent.Callable<V> task)
java.util.concurrent.Future<V>
take()
-
-
-
Constructor Detail
-
CountingCompletionService
public CountingCompletionService(java.util.concurrent.Executor executor)
-
CountingCompletionService
public CountingCompletionService(java.util.concurrent.Executor executor, java.util.concurrent.BlockingQueue<java.util.concurrent.Future<V>> queue)
-
-
Method Detail
-
take
public java.util.concurrent.Future<V> take() throws java.lang.InterruptedException
-
poll
public java.util.concurrent.Future<V> poll()
-
poll
public java.util.concurrent.Future<V> poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
-
getNumberOfCompletedTasks
public long getNumberOfCompletedTasks()
-
getNumberOfSubmittedTasks
public long getNumberOfSubmittedTasks()
-
hasUncompletedTasks
public boolean hasUncompletedTasks()
-
-