Interface PooledMessage.Pool
- All Known Subinterfaces:
MessagePoolAdapter
- All Known Implementing Classes:
SimpleMessagePool,VariableMessagePool
- Enclosing class:
- PooledMessage
public static interface PooledMessage.Pool
This is the interface for message pools. An empty message, ready for writing with the ByteBuffer.putXXX()
methods, is obtained from message.get(). The protected method recycle is called when the message is finished()
and call outstanding views have been returned with dropView(). Whether and how the pool recycles the message is a
strategy decision of the pool implementation.
-
Method Summary
Modifier and TypeMethodDescriptionget()Returns a message whose capacity is at least the pool's default size.get(int neededSize) Returns a message whose capacity is at least neededSize bytes.intReturn the largest buffer that can is managed by this pool.intReturn the smallest buffer that can is managed by this pool.voidCalled by the message when its producer is finished() and all outstanding views have been by the consumers with dropView().
-
Method Details
-
minBufferSize
int minBufferSize()Return the smallest buffer that can is managed by this pool. -
maxBufferSize
int maxBufferSize()Return the largest buffer that can is managed by this pool. -
get
Returns a message whose capacity is at least neededSize bytes. The underlying buffer's position() is set to zero and the limit() is set to capacity(). -
get
PooledMessage get()Returns a message whose capacity is at least the pool's default size. The underlying buffer's position() is set to zero and the limit() is set to capacity() -
recycle
Called by the message when its producer is finished() and all outstanding views have been by the consumers with dropView(). The pool can attempt to re-use the buffer storage (or not) as it sees fit. Note that although the method is public (it has to be, in a Java interface), it should only ever be called by the Message itself.
-