Class DirectByteBufferPool

java.lang.Object
org.jenkinsci.remoting.util.DirectByteBufferPool
All Implemented Interfaces:
ByteBufferPool

public class DirectByteBufferPool extends Object implements ByteBufferPool
A buffer pool that keeps a free list of ByteBuffers of a specified default size in a simple fixed size stack. If the stack is full, the buffer is de-referenced and available to be freed by normal garbage collection (whenever that may actually take place)
See Also:
  • Constructor Details

    • DirectByteBufferPool

      public DirectByteBufferPool(int minBufferSize, int maxPoolSize)
      Constructor.
      Parameters:
      minBufferSize - the minimum size to create buffers.
      maxPoolSize - the maximum buffers to keep in the pool.
  • Method Details

    • acquire

      public ByteBuffer acquire(int size)
      Borrow a buffer from the pool.
      Specified by:
      acquire in interface ByteBufferPool
      Parameters:
      size - The minimum size and initial limit of the buffer.
      Returns:
      the buffer.
    • release

      public void release(ByteBuffer buffer)
      Returns a buffer to the pool.
      Specified by:
      release in interface ByteBufferPool
      Parameters:
      buffer - the buffer.