public class ByteArrayPool extends java.lang.Object implements ByteArrayFactory
ByteArrays, using a pool to reduce allocation where possible.
WARNING: This code has never been run!| Modifier and Type | Class and Description |
|---|---|
private class |
ByteArrayPool.DirectBufferByteArray |
| Modifier and Type | Field and Description |
|---|---|
private boolean |
direct |
private int |
freeBufferCount |
private java.util.ArrayList<java.util.Stack<ByteArrayPool.DirectBufferByteArray>> |
freeBuffers |
private boolean |
freed |
private long |
freeMemory |
private int |
MAX_BITS |
private int |
maxFreeBuffers |
private int |
maxFreeMemory |
| Constructor and Description |
|---|
ByteArrayPool(boolean direct,
int maxFreeBuffers,
int maxFreeMemory)
Creates a new instance of ByteArrayPool.
|
| Modifier and Type | Method and Description |
|---|---|
private int |
bits(int index) |
ByteArray |
create(int size)
Creates a new instance of a
ByteArray |
void |
free()
Frees the buffers
|
private final int MAX_BITS
private boolean freed
private final boolean direct
private java.util.ArrayList<java.util.Stack<ByteArrayPool.DirectBufferByteArray>> freeBuffers
private int freeBufferCount
private long freeMemory
private final int maxFreeBuffers
private final int maxFreeMemory
public ByteArrayPool(boolean direct,
int maxFreeBuffers,
int maxFreeMemory)
direct - If we should use direct buffersmaxFreeBuffers - The maximum number of free buffersmaxFreeMemory - The maximum amount of free memory allowedpublic ByteArray create(int size)
ByteArraycreate in interface ByteArrayFactorysize - The size of the array to buildprivate int bits(int index)
public void free()