|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.netty.buffer.AbstractChannelBufferFactory
org.jboss.netty.buffer.DirectChannelBufferFactory
public class DirectChannelBufferFactory
A ChannelBufferFactory which pre-allocates a large chunk of direct
buffer and returns its slice on demand. Direct buffers are reclaimed via
ReferenceQueue in most JDK implementations, and therefore they are
deallocated less efficiently than an ordinary heap buffer. Consequently,
a user will get OutOfMemoryError when one tries to allocate small
direct buffers more often than the GC throughput of direct buffers, which
is much lower than the GC throughput of heap buffers. This factory avoids
this problem by allocating a large chunk of pre-allocated direct buffer and
reducing the number of the garbage collected internal direct buffer objects.
| Constructor Summary | |
|---|---|
DirectChannelBufferFactory()
Creates a new factory whose default ByteOrder is
ByteOrder.BIG_ENDIAN. |
|
DirectChannelBufferFactory(java.nio.ByteOrder defaultOrder)
Creates a new factory with the specified default ByteOrder. |
|
DirectChannelBufferFactory(java.nio.ByteOrder defaultOrder,
int preallocatedBufferCapacity)
Creates a new factory with the specified default ByteOrder. |
|
DirectChannelBufferFactory(int preallocatedBufferCapacity)
Creates a new factory whose default ByteOrder is
ByteOrder.BIG_ENDIAN. |
|
| Method Summary | |
|---|---|
ChannelBuffer |
getBuffer(java.nio.ByteBuffer nioBuffer)
Returns a ChannelBuffer whose content is equal to the sub-region
of the specified nioBuffer. |
ChannelBuffer |
getBuffer(java.nio.ByteOrder order,
byte[] array,
int offset,
int length)
Returns a ChannelBuffer whose content is equal to the sub-region
of the specified array. |
ChannelBuffer |
getBuffer(java.nio.ByteOrder order,
int capacity)
Returns a ChannelBuffer with the specified endianness
and capacity. |
static ChannelBufferFactory |
getInstance()
|
static ChannelBufferFactory |
getInstance(java.nio.ByteOrder defaultEndianness)
|
| Methods inherited from class org.jboss.netty.buffer.AbstractChannelBufferFactory |
|---|
getBuffer, getBuffer, getDefaultOrder |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DirectChannelBufferFactory()
ByteOrder is
ByteOrder.BIG_ENDIAN.
public DirectChannelBufferFactory(int preallocatedBufferCapacity)
ByteOrder is
ByteOrder.BIG_ENDIAN.
public DirectChannelBufferFactory(java.nio.ByteOrder defaultOrder)
ByteOrder.
defaultOrder - the default ByteOrder of this factory
public DirectChannelBufferFactory(java.nio.ByteOrder defaultOrder,
int preallocatedBufferCapacity)
ByteOrder.
defaultOrder - the default ByteOrder of this factory| Method Detail |
|---|
public static ChannelBufferFactory getInstance()
public static ChannelBufferFactory getInstance(java.nio.ByteOrder defaultEndianness)
public ChannelBuffer getBuffer(java.nio.ByteOrder order,
int capacity)
ChannelBufferFactoryChannelBuffer with the specified endianness
and capacity.
order - the endianness of the returned ChannelBuffercapacity - the capacity of the returned ChannelBuffer
ChannelBuffer with the specified endianness and
capacity, whose readerIndex and writerIndex
are 0
public ChannelBuffer getBuffer(java.nio.ByteOrder order,
byte[] array,
int offset,
int length)
ChannelBufferFactoryChannelBuffer whose content is equal to the sub-region
of the specified array. Depending on the factory implementation,
the returned buffer could wrap the array or create a new copy of
the array.
order - the endianness of the returned ChannelBufferarray - the byte arrayoffset - the offset of the byte arraylength - the length of the byte array
ChannelBuffer with the specified content,
whose readerIndex and writerIndex
are 0 and (length - offset) respectivelypublic ChannelBuffer getBuffer(java.nio.ByteBuffer nioBuffer)
ChannelBufferFactoryChannelBuffer whose content is equal to the sub-region
of the specified nioBuffer. Depending on the factory
implementation, the returned buffer could wrap the nioBuffer or
create a new copy of the nioBuffer.
nioBuffer - the NIO ByteBuffer
ChannelBuffer with the specified content,
whose readerIndex and writerIndex
are 0 and nioBuffer.remaining() respectively
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||