Package org.jenkinsci.remoting.util
Class DirectByteBufferPool
java.lang.Object
org.jenkinsci.remoting.util.DirectByteBufferPool
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquire(int size) Borrow a buffer from the pool.voidrelease(ByteBuffer buffer) Returns a buffer to the pool.
-
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
Borrow a buffer from the pool.- Specified by:
acquirein interfaceByteBufferPool- Parameters:
size- The minimum size and initial limit of the buffer.- Returns:
- the buffer.
-
release
Returns a buffer to the pool.- Specified by:
releasein interfaceByteBufferPool- Parameters:
buffer- the buffer.
-