Interface BufferPool
- All Known Implementing Classes:
CachingBufferPool, QuiescentBufferPool
public interface BufferPool
Makes various types of buffers available for use and potential re-use.
Implementations must be safe for concurrent use by multiple threads.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]allocateArray(int size) Returns abyte[]of size or greater length.allocateDirect(int size) Returns adirect ByteBufferof size or greatercapacity.voidreleaseArray(byte[] buffer) Returns instance to pool for potential future reuse.voidreleaseDirect(ByteBuffer buffer) Returns instance to pool for potential future reuse.
-
Method Details
-
allocateArray
byte[] allocateArray(int size) Returns abyte[]of size or greater length.- Parameters:
size- The minimum size array required. Must be>= 0.- Returns:
- A
byte[]with length of at least size. - See Also:
-
releaseArray
void releaseArray(byte[] buffer) Returns instance to pool for potential future reuse.Must not be returned more than 1 time. Must not be used by caller after return.
- Parameters:
buffer- Instance to return to pool. Must not benull. Must not be returned more than 1 time. Must not be used by caller after return.
-
allocateDirect
Returns adirect ByteBufferof size or greatercapacity.- Parameters:
size- The minimum size buffer required. Must be>= 0.- Returns:
- A
ByteBufferof size or greatercapacity. - See Also:
-
releaseDirect
Returns instance to pool for potential future reuse.Must not be returned more than 1 time. Must not be used by caller after return.
- Parameters:
buffer- Instance to return to pool. Must not benull. Must not be returned more than 1 time. Must not be used by caller after return.
-