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()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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

    - #### submit

          public java.util.concurrent.Future<V> submit​(java.util.concurrent.Callable<V> task)

      Specified by:
        `submit` in interface `java.util.concurrent.CompletionService<V>`
      Overrides:
        `submit` in class `java.util.concurrent.ExecutorCompletionService<V>`

    - #### submit

          public java.util.concurrent.Future<V> submit​(java.lang.Runnable task,
                                                       V result)

      Specified by:
        `submit` in interface `java.util.concurrent.CompletionService<V>`
      Overrides:
        `submit` in class `java.util.concurrent.ExecutorCompletionService<V>`

    - #### take

          public java.util.concurrent.Future<V> take()
                                              throws java.lang.InterruptedException

      Specified by:
        `take` in interface `java.util.concurrent.CompletionService<V>`
      Overrides:
        `take` in class `java.util.concurrent.ExecutorCompletionService<V>`
      Throws:
        `java.lang.InterruptedException`

    - #### poll

          public java.util.concurrent.Future<V> poll()

      Specified by:
        `poll` in interface `java.util.concurrent.CompletionService<V>`
      Overrides:
        `poll` in class `java.util.concurrent.ExecutorCompletionService<V>`

    - #### poll

          public java.util.concurrent.Future<V> poll​(long timeout,
                                                     java.util.concurrent.TimeUnit unit)
                                              throws java.lang.InterruptedException

      Specified by:
        `poll` in interface `java.util.concurrent.CompletionService<V>`
      Overrides:
        `poll` in class `java.util.concurrent.ExecutorCompletionService<V>`
      Throws:
        `java.lang.InterruptedException`

    - #### getNumberOfCompletedTasks

          public long getNumberOfCompletedTasks()

    - #### getNumberOfSubmittedTasks

          public long getNumberOfSubmittedTasks()

    - #### hasUncompletedTasks

          public boolean hasUncompletedTasks()