Top Description Methods
org.glassfish.grizzly.memory

public Interface ThreadLocalPool<E>

Known Direct Implementers
org.glassfish.grizzly.memory.ByteBufferManager.ByteBufferThreadLocalPool, org.glassfish.grizzly.memory.HeapMemoryManager.HeapBufferThreadLocalPool
Type Parameters
<E>
Type of Buffer that will be created

A thread local pool used by a MemoryManager to create and modify Buffers
See Also
java.nio.Buffer, org.glassfish.grizzly.Buffer

Method Summary

Modifier and TypeMethod and Description
public E

Returns:

the new buffer
allocate
(int
maximum number of elements
size
)

Creates a buffer with a given capacity and limit

public boolean

Returns:

true if there are unused elements, false otherwise
hasRemaining
()

Whether there are elements between the current position and the end

public boolean

Returns:

true if the end of the buffer has been allocated, false otherwise
isLastAllocated
(E
the buffer to check
oldBuffer
)

Whether the last element in the buffer has been set

public E

Returns:

the new Buffer or null if the buffer could not be resized
reallocate
(E
Old Buffer containing data
oldBuffer
,
int
The size the new Buffer should be.
newSize
)

Creates a new Buffer with a set size and assigns it the data that was held in the old one as long as the given size is not smaller than the data held.

public E

Returns:

the old buffer data that was removed. This may be null.
reduceLastAllocated
(E buffer)

Reduces the buffer to the last data allocated

public boolean

Returns:

true if operation successfully completed, false otherwise
release
(E
the buffer to release
underlyingBuffer
)

deallocates the data in the buffer

public int

Returns:

number of elements
remaining
()

Gets the number of elements between the current position and the limit

public void
reset(E
the buffer to reset
pool
)

Resets the Buffer to empty values and empties the pool

public boolean

Returns:

true if the the buffer should be enlarged to hold the desired size
wantReset
(int
the desired size of the buffer. If this is less than the current size ofthe buffer then this will return false
size
)

Checks if the size of the Buffer should be reset.

Method Detail

allocateback to summary
public E allocate(int size)

Creates a buffer with a given capacity and limit

Parameters
size:int

maximum number of elements

Returns:E

the new buffer

See Also
java.nio.ByteBuffer#allocate(int)
hasRemainingback to summary
public boolean hasRemaining()

Whether there are elements between the current position and the end

Returns:boolean

true if there are unused elements, false otherwise

isLastAllocatedback to summary
public boolean isLastAllocated(E oldBuffer)

Whether the last element in the buffer has been set

Parameters
oldBuffer:E

the buffer to check

Returns:boolean

true if the end of the buffer has been allocated, false otherwise

reallocateback to summary
public E reallocate(E oldBuffer, int newSize)

Creates a new Buffer with a set size and assigns it the data that was held in the old one as long as the given size is not smaller than the data held.

Parameters
oldBuffer:E

Old Buffer containing data

newSize:int

The size the new Buffer should be.

Returns:E

the new Buffer or null if the buffer could not be resized

reduceLastAllocatedback to summary
public E reduceLastAllocated(E buffer)

Reduces the buffer to the last data allocated

Returns:E

the old buffer data that was removed. This may be null.

releaseback to summary
public boolean release(E underlyingBuffer)

deallocates the data in the buffer

Parameters
underlyingBuffer:E

the buffer to release

Returns:boolean

true if operation successfully completed, false otherwise

remainingback to summary
public int remaining()

Gets the number of elements between the current position and the limit

Returns:int

number of elements

resetback to summary
public void reset(E pool)

Resets the Buffer to empty values and empties the pool

Parameters
pool:E

the buffer to reset

wantResetback to summary
public boolean wantReset(int size)

Checks if the size of the Buffer should be reset.

Parameters
size:int

the desired size of the buffer. If this is less than the current size ofthe buffer then this will return false

Returns:boolean

true if the the buffer should be enlarged to hold the desired size