Package org.apache.mina.util.byteaccess
Class ByteArrayPool
- java.lang.Object
-
- org.apache.mina.util.byteaccess.ByteArrayPool
-
- All Implemented Interfaces:
ByteArrayFactory
public class ByteArrayPool extends java.lang.Object implements ByteArrayFactory
CreatesByteArrays, using a pool to reduce allocation where possible. WARNING: This code has never been run!
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classByteArrayPool.DirectBufferByteArray
-
Field Summary
Fields Modifier and Type Field Description private booleandirectprivate intfreeBufferCountprivate java.util.ArrayList<java.util.Stack<ByteArrayPool.DirectBufferByteArray>>freeBuffersprivate booleanfreedprivate longfreeMemoryprivate intMAX_BITSprivate intmaxFreeBuffersprivate intmaxFreeMemory
-
Constructor Summary
Constructors Constructor Description ByteArrayPool(boolean direct, int maxFreeBuffers, int maxFreeMemory)Creates a new instance of ByteArrayPool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intbits(int index)ByteArraycreate(int size)Creates a new instance of aByteArrayvoidfree()Frees the buffers
-
-
-
Field Detail
-
MAX_BITS
private final int MAX_BITS
- See Also:
- Constant Field Values
-
freed
private boolean freed
-
direct
private final boolean direct
-
freeBuffers
private java.util.ArrayList<java.util.Stack<ByteArrayPool.DirectBufferByteArray>> freeBuffers
-
freeBufferCount
private int freeBufferCount
-
freeMemory
private long freeMemory
-
maxFreeBuffers
private final int maxFreeBuffers
-
maxFreeMemory
private final int maxFreeMemory
-
-
Constructor Detail
-
ByteArrayPool
public ByteArrayPool(boolean direct, int maxFreeBuffers, int maxFreeMemory)Creates a new instance of ByteArrayPool.- Parameters:
direct- If we should use direct buffersmaxFreeBuffers- The maximum number of free buffersmaxFreeMemory- The maximum amount of free memory allowed
-
-
Method Detail
-
create
public ByteArray create(int size)
Creates a new instance of aByteArray- Specified by:
createin interfaceByteArrayFactory- Parameters:
size- The size of the array to build- Returns:
- The ByteArray
-
bits
private int bits(int index)
-
free
public void free()
Frees the buffers
-
-