Class RetainableByteBuffer

All Implemented Interfaces:

public class RetainableByteBuffer extends Object implements Retainable

A pooled ByteBuffer which maintains a reference count that is incremented with retain() and decremented with release(). The buffer is released to the pool when release() is called one more time than retain().

A RetainableByteBuffer can either be:

Calling release() on a out of pool and retained instance does not re-pool it while that re-pools it on a out of pool but not retained instance.

  • Method Details

    • capacity

      public int capacity()
    • getBuffer

      public ByteBuffer getBuffer()
    • getLastUpdate

      public long getLastUpdate()
    • isRetained

      public boolean isRetained()
      Checks if retain() has been called at least one more time than release().
      true if this buffer is retained, false otherwise.
    • isDirect

      public boolean isDirect()
    • retain

      public void retain()
      Increments the retained counter of this buffer.
      Specified by:
      retain in interface Retainable
    • release

      public boolean release()
      Decrements the retained counter of this buffer.
      true if the buffer was re-pooled, false otherwise.
    • remaining

      public int remaining()
    • hasRemaining

      public boolean hasRemaining()
    • isEmpty

      public boolean isEmpty()
    • clear

      public void clear()
    • toString

      public String toString()
      toString in class Object