Class SharedBuffer<T>

java.lang.Object
de.iip_ecosphere.platform.connectors.SharedBuffer<T>
Type Parameters:
T - the entity type

public class SharedBuffer<T> extends Object
A shared producer/consumer buffer.
Author:
Holger Eichelberger, SSE
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Queue<T>
     
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SharedBuffer(int capacity)
    Creates the buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the buffer.
    void
    offer(T value)
    Offers an entity to the queue.
    Polls an entity from the buffer; if there is none, waits for the next entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • buffer

      private final Queue<T> buffer
    • capacity

      private final int capacity
  • Constructor Details

    • SharedBuffer

      public SharedBuffer(int capacity)
      Creates the buffer.
      Parameters:
      capacity - the initial capacity
  • Method Details

    • offer

      public void offer(T value) throws InterruptedException
      Offers an entity to the queue.
      Parameters:
      value - the value to be offered
      Throws:
      InterruptedException
    • poll

      public T poll() throws InterruptedException
      Polls an entity from the buffer; if there is none, waits for the next entity.
      Returns:
      the entity
      Throws:
      InterruptedException - if waiting is interrupted
    • clear

      public void clear()
      Clears the buffer.