|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.memory.ByteBufferWrapper
com.sun.grizzly.memory.slab.SlabByteBufferWrapper
public class SlabByteBufferWrapper
The SlabByteBufferWrapper knows both the MemoryManager and the slab used to allocate it. Both are needed in the BufferWrapper.trim() and BufferWrapper.dispose() methods: trim() is used to allocate a buffer as large as the free space in a slab for reading, so that very large reads can be made efficiently. After reading the data, trim() is called in order to reduce the space needed to the actual data read. This works best in the case where a slab is used by a single reader thread, which is the expected mode of use. dispose() is used to release a buffer once the stream is done with it (directly from the Reader, most likely as part of the BufferHandler in the Writer). Here both the allocator and the slab are needed: the slab tracks whether or not all of its allocated space has been freed, and the allocator (in the pool case by delegating to the SlabPoolImpl) tracks empty, partial and full slabs for recycling memory.
| Field Summary |
|---|
| Fields inherited from class com.sun.grizzly.memory.ByteBufferWrapper |
|---|
DEBUG_MODE, memoryManager, visible |
| Constructor Summary | |
|---|---|
SlabByteBufferWrapper(ByteBufferManager allocator,
Slab slab,
int size)
Allocate a buffer that contains dataSize data. |
|
| Method Summary | |
|---|---|
void |
dispose()
Notify the allocator that the space for this BufferWrapper is no longer needed. |
String |
toString()
|
void |
trim()
Trim the buffer by reducing capacity to position, if possible. |
| Methods inherited from class com.sun.grizzly.memory.ByteBufferWrapper |
|---|
asReadOnlyBuffer, capacity, clear, compact, compareTo, contentAsString, duplicate, equals, flip, get, get, get, get, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, hashCode, hasRemaining, isReadOnly, limit, limit, mark, order, order, position, position, prepend, put, put, put, put, put, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putShort, putShort, remaining, reset, rewind, slice, underlying |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SlabByteBufferWrapper(ByteBufferManager allocator,
Slab slab,
int size)
| Method Detail |
|---|
public void trim()
trim in interface Buffer<ByteBuffer>trim in class ByteBufferWrapperpublic void dispose()
dispose in interface Buffer<ByteBuffer>dispose in class ByteBufferWrapperpublic String toString()
toString in class ByteBufferWrapper
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||