|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.memory.ByteBufferManager
com.sun.grizzly.memory.slab.SlabMemoryManagerBase
public abstract class SlabMemoryManagerBase
Base class for implementing an SlabMemory Allocator. All subclasses must implement dispose, releaseSlab and obtainSlab, as well as the undefined methods in the Allocator interface: maxAllocationSize, bufferType, and close. For the aim of avoiding contention on allocate() and supporting Buffer.trim() SlabMemoryManagerBase associates each calling Thread with ist own Slab. If calling Thread happens to be WorkerThread Slab is stored in WorkerThread's Attributes otherwise Threadlocal storage is used. The Thread associated Slab serves as a memory depot for allocating BufferWrappers. If a Slab's space is exhausted obtainSlab will provide a empty Slab which will replace the calling Thread's exhausted Slab.
| Field Summary |
|---|
| Fields inherited from class com.sun.grizzly.memory.ByteBufferManager |
|---|
isDirect |
| Method Summary | |
|---|---|
SlabByteBufferWrapper |
allocate(int size)
Allocated Buffer of the required size. |
Buffer |
allocate(int minSize,
int maxSize)
|
abstract void |
dispose(Slab slab,
ByteBuffer store)
|
abstract int |
maxAllocationSize()
Returns the maximum size that can be allocated by an allocate( int ) call. |
ByteBufferWrapper |
reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Reallocate Buffer to a required size. |
void |
release(ByteBufferWrapper buffer)
Lets JVM Garbage collector to release buffer. |
| Methods inherited from class com.sun.grizzly.memory.ByteBufferManager |
|---|
allocate0, isDirect, setDirect, wrap, wrap, wrap, wrap, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public abstract void dispose(Slab slab,
ByteBuffer store)
public abstract int maxAllocationSize()
public SlabByteBufferWrapper allocate(int size)
ByteBufferManagerBuffer of the required size.
allocate in interface MemoryManager<ByteBufferWrapper>allocate in class ByteBufferManagersize - Buffer size to be allocated.
Buffer.
public final Buffer allocate(int minSize,
int maxSize)
public void release(ByteBufferWrapper buffer)
ByteBufferManager
release in interface MemoryManager<ByteBufferWrapper>release in class ByteBufferManagerbuffer - Buffer to be released.
public ByteBufferWrapper reallocate(ByteBufferWrapper oldBuffer,
int newSize)
ByteBufferManagerBuffer 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||