Package org.apache.cassandra.io.util
Class SimpleCachedBufferPool
- java.lang.Object
-
- org.apache.cassandra.io.util.SimpleCachedBufferPool
-
public class SimpleCachedBufferPool extends java.lang.Object
A very simple Bytebuffer pool with a fixed allocation size and a cached max allocation count. Will allow you to go past the "max", freeing all buffers allocated beyond the max buffer count on release. Has a reusable thread local ByteBuffer that users can make use of.
-
-
Constructor Summary
Constructors Constructor Description SimpleCachedBufferPool(int maxBufferPoolSize, int bufferSize, BufferType preferredReusableBufferType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
atLimit()
Checks if the number of used buffers has exceeded the maximum number of cached buffers.java.nio.ByteBuffer
createBuffer()
void
emptyBufferPool()
Empties the buffer pool.java.nio.ByteBuffer
getThreadLocalReusableBuffer(int size)
void
releaseBuffer(java.nio.ByteBuffer buffer)
java.lang.String
toString()
-
-
-
Constructor Detail
-
SimpleCachedBufferPool
public SimpleCachedBufferPool(int maxBufferPoolSize, int bufferSize, BufferType preferredReusableBufferType)
-
-
Method Detail
-
createBuffer
public java.nio.ByteBuffer createBuffer()
-
getThreadLocalReusableBuffer
public java.nio.ByteBuffer getThreadLocalReusableBuffer(int size)
-
releaseBuffer
public void releaseBuffer(java.nio.ByteBuffer buffer)
-
emptyBufferPool
public void emptyBufferPool()
Empties the buffer pool.
-
atLimit
public boolean atLimit()
Checks if the number of used buffers has exceeded the maximum number of cached buffers.- Returns:
true
if the number of used buffers has exceeded the maximum number of cached buffers,false
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-