org.springframework.batch.repeat.support

## Class ResultHolderResultQueue

- java.lang.Object
- - org.springframework.batch.repeat.support.ResultHolderResultQueue

-     public class ResultHolderResultQueue
      extends java.lang.Object

  An implementation of the `ResultQueue` that throttles the number of expected results, limiting it to a maximum at any given time.
  Author:
    Dave Syer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResultHolderResultQueue(int throttleLimit)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `expect()` Tell the queue to expect one more result.
    `boolean` | `isEmpty()` Used by manager thread to verify that there are results available from `take()` without possibly having to block and wait.
    `boolean` | `isExpecting()` Check if any results are expected.
    `void` | `put(org.springframework.batch.repeat.support.ResultHolder holder)` Once it is expecting a result, clients call this method to satisfy the expectation.
    `org.springframework.batch.repeat.support.ResultHolder` | `take()` Get the next result as soon as it becomes available.

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

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

- - ### Constructor Detail

    - #### ResultHolderResultQueue

          public ResultHolderResultQueue(int throttleLimit)

      Parameters:
        `throttleLimit` - the maximum number of results that can be expected at any given time.

  - ### Method Detail

    - #### isEmpty

          public boolean isEmpty()

      Used by manager thread to verify that there are results available from `take()` without possibly having to block and wait.
      Returns:
        true if there are no results available

    - #### isExpecting

          public boolean isExpecting()

      Check if any results are expected. Usually used by manager thread to drain queue when it is finished.
      Returns:
        true if more results are expected, but possibly not yet available.

    - #### expect

          public void expect()
                      throws java.lang.InterruptedException

      Tell the queue to expect one more result. Blocks until a new result is available if already expecting too many (as determined by the throttle limit).
      Throws:
        `java.lang.InterruptedException` - if the call blocks and is then interrupted.
      See Also:
        `ResultQueue.expect()`

    - #### put

          public void put(org.springframework.batch.repeat.support.ResultHolder holder)
                   throws java.lang.IllegalArgumentException

      Once it is expecting a result, clients call this method to satisfy the expectation. In a manager-worker pattern, the workers call this method to deposit the result of a finished task on the queue for collection.
      Parameters:
        `holder` - the result for later collection.
      Throws:
        `java.lang.IllegalArgumentException` - if the queue is not expecting a new result

    - #### take

          public org.springframework.batch.repeat.support.ResultHolder take()
                                                                     throws java.util.NoSuchElementException,
                                                                            java.lang.InterruptedException

      Get the next result as soon as it becomes available.
      Release result immediately if:
      - There is a result that is continuable.
      Otherwise block if either:
      - There is no result (as per contract of `ResultQueue`).
      - The number of results is less than the number expected.
      Error if either:
      - Not expecting.
      - Interrupted.
      Returns:
        a result previously deposited
      Throws:
        `java.util.NoSuchElementException` - if there is no result expected
        `java.lang.InterruptedException` - if the operation is interrupted while waiting
      See Also:
        `ResultQueue.take()`