org.modeshape.common.collection.ring

## Interface PointerBarrier

- All Superinterfaces:
    AutoCloseable

      public interface PointerBarrier
      extends AutoCloseable

  A barrier that encapsulates a `Pointer` and that will `wait` to advance it until it is safe to do so and there are entries available to read. This is used within the `RingBuffer.addConsumer(C)` method to provide each consumer with a valid `Pointer` that stays as close as possible behind the ring buffer's `Cursor`.
  See Also:
    `Cursor.newBarrier()`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Signal that this barrier is closed and should return -1 from `waitFor(long)`.
    `boolean` | `isComplete()` Return whether this barrier has completed and should no longer be used.
    `long` | `waitFor(long position)` Wait for the given position to be available for consumption.

- - ### Method Detail

    - #### waitFor

          long waitFor(long position)
                       throws InterruptedException,
                              TimeoutException

      Wait for the given position to be available for consumption.
      Parameters:
        `position` - the sequence to wait for
      Returns:
        the position up to which is available, which may be larger than the requested position or a negative number if there will never be any more positions
      Throws:
        `InterruptedException` - if the thread needs awaking on a condition variable.
        `TimeoutException` - if this blocking method times out

    - #### isComplete

          boolean isComplete()

      Return whether this barrier has completed and should no longer be used.
      Returns:
        true if this barrier is complete, or false otherwise

    - #### close

          void close()

      Signal that this barrier is closed and should return -1 from `waitFor(long)`.
      Specified by:
        `close` in interface `AutoCloseable`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.