|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.memory.ByteBufferManager
org.glassfish.grizzly.memory.ByteBufferViewManager
public class ByteBufferViewManager
The ByteBufferManager implementation, which doesn't allocate
ByteBuffers each time allocate is called. Instead of this,
implementation preallocates large ByteBuffer pool, and returns
ByteBuffer view of required size for each allocate method call.
MemoryManager,
ByteBufferManager,
ByteBuffer| Field Summary | |
|---|---|
protected int |
capacity
Capacity of the large ByteBuffer pool. |
static int |
DEFAULT_CAPACITY
The default capacity of the ByteBuffer from which views
will be created. |
protected ByteBuffer |
largeByteBuffer
Large ByteBuffer pool. |
| Fields inherited from class org.glassfish.grizzly.memory.ByteBufferManager |
|---|
isDirect |
| Constructor Summary | |
|---|---|
ByteBufferViewManager()
|
|
ByteBufferViewManager(boolean isDirect)
|
|
ByteBufferViewManager(boolean isDirect,
int capacity)
|
|
| Method Summary | |
|---|---|
ByteBufferWrapper |
allocate(int size)
Allocates Buffer of required size, which is actually sliced from
large preallocated ByteBuffer pool. |
ByteBufferWrapper |
reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Reallocate Buffer to a required size. |
protected static ByteBuffer |
slice(ByteBuffer chunk,
int size)
Slice ByteBuffer of required size from big chunk. |
| Methods inherited from class org.glassfish.grizzly.memory.ByteBufferManager |
|---|
allocate0, isDirect, release, setDirect, wrap, wrap, wrap, wrap, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_CAPACITY
ByteBuffer from which views
will be created.
protected ByteBuffer largeByteBuffer
ByteBuffer pool.
protected int capacity
ByteBuffer pool.
| Constructor Detail |
|---|
public ByteBufferViewManager()
public ByteBufferViewManager(boolean isDirect)
public ByteBufferViewManager(boolean isDirect,
int capacity)
| Method Detail |
|---|
public ByteBufferWrapper allocate(int size)
Buffer of required size, which is actually sliced from
large preallocated ByteBuffer pool.
allocate in interface MemoryManager<ByteBufferWrapper>allocate in class ByteBufferManagersize - size of the Buffer to be allocated.
Buffer of required size, which is actualled sliced from
large preallocated ByteBuffer pool.
public ByteBufferWrapper reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Buffer to a required size.
Implementation may choose the way, how reallocation could be done, either
by allocating new Buffer of required size and copying old
Buffer content there, or perform more complex logic related to
memory pooling etc.
reallocate in interface MemoryManager<ByteBufferWrapper>reallocate in class ByteBufferManageroldBuffer - old Buffer to be reallocated.newSize - new Buffer required size.
Buffer.
protected static ByteBuffer slice(ByteBuffer chunk,
int size)
ByteBuffer of required size from big chunk.
chunk - big ByteBuffer pool.size - required slice size.
ByteBuffer of required size.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||