BufferPool implementation which caches values at fixed sizes.
Pooled instances are held as SoftReference to allow GC if necessary.
The current fixed sizes are calculated as follows:
Integer#MAX_VALUE| Modifier and Type | Class and Description |
|---|---|
| private static interface |
| Modifier and Type | Field and Description |
|---|---|
| private static final CachingBufferPool. | |
| private final ConcurrentMap | |
| private final ConcurrentMap | |
| private static final CachingBufferPool. | |
| private static final CachingBufferPool |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static int | |
| public byte[] | allocateArray(int
The minimum size array required. Must be size)>= 0.Implements org. Returns a |
| public ByteBuffer | allocateDirect(int
The minimum size buffer required. Must be size)>= 0.Implements org. Returns a |
| public static BufferPool | Returns: instance ofCachingBufferPool for using cached buffers.Returns instance of |
| private static <E> E | getOrCreate(final int size, final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map, final CachingBufferPool.
|
| private static <E> ConcurrentLinkedDeque | optimisticGetEntry(Integer key, ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map)
|
| public void | releaseArray(byte[]
Instance to return to pool. Must not be buffer)null.
Must not be returned more than 1 time. Must not be used by caller after return.Implements org. Returns instance to pool for potential future reuse. |
| public void | releaseDirect(ByteBuffer
Instance to return to pool. Must not be buffer)null.
Must not be returned more than 1 time. Must not be used by caller after return.Implements org. Returns instance to pool for potential future reuse. |
| private static <E> void | returnValue(E value, Integer size, ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map)
|
| private static int | |
| public String |
| ARRAY_FUNCTION | back to summary |
|---|---|
| private static final CachingBufferPool. | |
| buffers | back to summary |
|---|---|
| private final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<ByteBuffer>>> buffers | |
| bytes | back to summary |
|---|---|
| private final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<byte[]>>> bytes | |
| DBB_FUNCTION | back to summary |
|---|---|
| private static final CachingBufferPool. | |
| INSTANCE | back to summary |
|---|---|
| private static final CachingBufferPool INSTANCE | |
| CachingBufferPool | back to summary |
|---|---|
| private CachingBufferPool() | |
| adjustSize | back to summary |
|---|---|
| pack-priv static int adjustSize(int size) | |
| allocateArray | back to summary |
|---|---|
| public byte[] allocateArray(int size) Implements org. Doc from org. Returns a
| |
| allocateDirect | back to summary |
|---|---|
| public ByteBuffer allocateDirect(int size) Implements org. Doc from org. Returns a
| |
| getInstance | back to summary |
|---|---|
| public static BufferPool getInstance() Returns instance of
| |
| getOrCreate | back to summary |
|---|---|
| private static <E> E getOrCreate(final int size, final ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map, final CachingBufferPool. | |
| optimisticGetEntry | back to summary |
|---|---|
| private static <E> ConcurrentLinkedDeque | |
| releaseArray | back to summary |
|---|---|
| public void releaseArray(byte[] buffer) Implements org. Doc from org. Returns instance to pool for potential future reuse. Must not be returned more than 1 time. Must not be used by caller after return.
| |
| releaseDirect | back to summary |
|---|---|
| public void releaseDirect(ByteBuffer buffer) Implements org. Doc from org. Returns instance to pool for potential future reuse. Must not be returned more than 1 time. Must not be used by caller after return.
| |
| returnValue | back to summary |
|---|---|
| private static <E> void returnValue(E value, Integer size, ConcurrentMap<Integer, ConcurrentLinkedDeque<SoftReference<E>>> map) | |
| roundToPowers | back to summary |
|---|---|
| private static int roundToPowers(int number, int bits) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Method and Description |
|---|---|
| public E |
| create | back to summary |
|---|---|
| public E create(int size) | |