| Modifier and Type | Field and Description |
|---|---|
static ChunkPool |
DEFAULT
Default pool instance with default parameters.
|
| Constructor and Description |
|---|
ChunkPool(String poolName,
int threadLocalCapacity,
int chunkPoolCapacity,
int chunkListPoolCapacity,
int chunkSize,
int recyclableChunkListCapacity)
Constructs new pool with specified parameters.
|
| Modifier and Type | Method and Description |
|---|---|
ChunkList |
copyToChunkList(byte[] bytes,
int offset,
int length,
Object owner)
Extracts a
ChunkList from the pool for specified owner
and fills it with data from specified byte array. |
protected Chunk |
createNewChunk(Object owner)
Constructs new
Chunk instance for specified owner. |
protected ChunkList |
createNewChunkList(Object owner)
Constructs a new
ChunkList of specified owner. |
Chunk |
getChunk(Object owner)
Extracts a
Chunk from the pool (or creates new one if the pool
is empty). |
ChunkList |
getChunkList(Object owner)
Extracts a
ChunkList from the pool (or creates new one if
the pool is empty). |
int |
getChunkSize()
Returns chunk size of this pool.
|
protected void |
recycleChunk(Chunk chunk,
Object owner)
Returns the specified
Chunk into the pool. |
protected void |
recycleChunkList(ChunkList chunkList,
Object owner)
Returns the specified
ChunkList into the pool. |
String |
toString()
Returns a string representation of the object.
|
public static final ChunkPool DEFAULT
ChunkList that is kept in the pool (1024 by default).public ChunkPool(String poolName, int threadLocalCapacity, int chunkPoolCapacity, int chunkListPoolCapacity, int chunkSize, int recyclableChunkListCapacity)
poolName - the base name of the pool.threadLocalCapacity - the capacity of thread-local pool, e.g. how many objects are pooled per thread.chunkPoolCapacity - maximum number of chunks to pool.chunkListPoolCapacity - maximum number of chunk lists to pool.chunkSize - size of the chunk.recyclableChunkListCapacity - maximum allowed chunk list capacity.public int getChunkSize()
public Chunk getChunk(Object owner)
Chunk from the pool (or creates new one if the pool
is empty). The returned chunk is not read-only, has non-zero length and belongs
to specified owner.
The default implementation returns Chunk with zero
offset and length
equal to underlying byte array length, however subclasses' behaviour
may differ.
owner - owner for the chunkpublic ChunkList getChunkList(Object owner)
ChunkList from the pool (or creates new one if
the pool is empty). The returned chunk list is
empty, not read-only and belongs to specified owner.owner - owner for the chunk listpublic ChunkList copyToChunkList(byte[] bytes, int offset, int length, Object owner)
ChunkList from the pool for specified owner
and fills it with data from specified byte array.bytes - byte array to take data fromoffset - offset of data within the arraylength - length of dataowner - owner for the chunk listprotected Chunk createNewChunk(Object owner)
Chunk instance for specified owner.owner - owner for the chunkprotected ChunkList createNewChunkList(Object owner)
ChunkList of specified owner.owner - owner for the chunk listprotected void recycleChunk(Chunk chunk, Object owner)
Chunk into the pool.
This method is invoked by Chunk.recycle(Object) method.chunk - a chunk to recycleowner - current owner of the chunkIllegalStateException - if the chunk's owner differs from the one specified
or if the chunk is read-onlyIllegalArgumentException - if the chunk does not belong to this pool or has invalid lengthprotected void recycleChunkList(ChunkList chunkList, Object owner)
ChunkList into the pool.
This method is invoked from ChunkList.recycle(Object) method.chunkList - a chunk list to recycleowner - current owner of the chunk listIllegalStateException - if the chunk's owner differs from the one specified
or if the chunk is read-onlyIllegalArgumentException - if the chunk list does not belong to this pool or is not emptyCopyright © 2002–2025 Devexperts LLC. All rights reserved.