Package fr.gouv.vitam.common.stream

# Class BoundedByteBuffer

java.lang.Object
fr.gouv.vitam.common.stream.BoundedByteBuffer

All Implemented Interfaces:
  `AutoCloseable`

public class BoundedByteBuffer extends Object implements AutoCloseable
Buffer with buffering allowing One Writer and Multiple Readers. - Storage is done in a fixed size circular buffer (https://en.wikipedia.org/wiki/Circular_buffer) - Reader & writers are synchronized using multiple Producer-Consumer locks : (https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem) - Writer can write till circular buffer is full. Then it blocks until free space is available (ALL readers have read some data) - Reader cannot read till the Writer writes data to the circular buffer.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `class`
  `BoundedByteBuffer.Writer`
  Writes data to the `BoundedByteBuffer` At the end of data, should write and End Of File (EOF) using the writeEOF() method Closing the Writer without EOF would throw a IOException (Broken stream) Non thread safe.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BoundedByteBuffer(int bufferSize, int readerCount)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `InputStream`
  `getReader(int index)`
  `BoundedByteBuffer.Writer`
  `getWriter()`

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

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

- ## Constructor Details

  - ### BoundedByteBuffer

    public BoundedByteBuffer(int bufferSize, int readerCount)

- ## Method Details

  - ### getWriter

    public BoundedByteBuffer.Writer getWriter()

  - ### getReader

    public InputStream getReader(int index)

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`