|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.pkt.PktIOBuffer
public final class PktIOBuffer
Implements an IO buffer.
A packet IO buffer is essentially a poolable ByteBuffer
. It
serves as the unit for IO (network or otherwise). A packet buffers
(PktBuffer
) serves as window into an IO buffer. The window
spans the contents of the packet header or body that the packet
buffer backs.
ByteBuffer
object, a packet buffer
is not thread safe i.e. only one thread can be executing the packet buffer
methods at any point in time.Field Summary | |
---|---|
static boolean |
DISABLE_NATIVE_BUFFERS
|
Method Summary | |
---|---|
PktIOBuffer |
acquire()
Acquire a reference to an IO buffer This method increments an IO buffer's ownership count. |
static PktIOBuffer |
create(int length,
boolean isNative)
Create a new IO buffer |
static PktIOBuffer |
createNative(int length)
Force create a native buffer |
void |
dispose()
Dispose of an IO buffer. |
ByteBuffer |
getBuffer()
Get the underlying byte buffer. |
int |
getCapacity()
Get the buffer capacity |
int |
getLimit()
Get the buffer limit |
int |
getOwnerCount()
Get an IO buffer's ownership count. |
com.neeve.util.UtlPool<PktIOBuffer> |
getPool()
Implementation of UtlPool.Item#getPool. |
PktIOBuffer |
init()
Implementation of UtlPool.Item#init. |
boolean |
isNative()
Get whether underlying buffer is native |
static boolean |
isNativePktIOBufferEnabled()
|
static int |
numSlabs()
Get the number of slabs |
com.neeve.util.UtlReferenceTracker |
referenceTracker()
|
PktIOBuffer |
setByteOrder(ByteOrder order)
Set the buffer byte ordering |
PktIOBuffer |
setLimit(int val)
Set the buffer limit An IO buffer limit serves as the marker for the maximum length of the buffer. |
PktIOBuffer |
setPool(com.neeve.util.UtlPool<PktIOBuffer> pool)
Implementation of UtlPool.Item#setPool. |
static int |
slab(int x)
|
static int |
smallestSlabSize()
Get the smallest slab size |
String |
toString()
Return a string representation of a buffer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final boolean DISABLE_NATIVE_BUFFERS
Method Detail |
---|
public static final boolean isNativePktIOBufferEnabled()
PktIOBuffer
s are enabled.public static PktIOBuffer create(int length, boolean isNative)
length
- The length of the buffer to create.isNative
- Whether to create a buffer with native or heap storage.
public static PktIOBuffer createNative(int length)
length
- The length of the buffer to create.
This method creates a native buffer regardless of whether or not
DISABLE_NATIVE_BUFFERS
is true
. This method should
only be used in cases where a native buffer is an absolute necessity,
e.g. when working with native code that requires such a buffer.
public static final int slab(int x)
public static final int smallestSlabSize()
public static final int numSlabs()
public final PktIOBuffer setByteOrder(ByteOrder order)
public final PktIOBuffer setLimit(int val)
An IO buffer limit serves as the marker for the maximum length of the buffer. The user of an IO buffer must ensure that data is not written beyond the limit marker since the IO buffer only wipes data upto the limit marker when recycled through its pool.
public final int getLimit()
public final int getCapacity()
public final ByteBuffer getBuffer()
public final boolean isNative()
public final PktIOBuffer acquire()
This method increments an IO buffer's ownership count. Buffer
ownership is used in conjunction with managing buffer pools.
If a buffer is tagged to an object pool, the buffer is released
back to the pool by dispose()
when the ownership count
reduces to 0. If not tagged to a pool, change of ownership
count has no side effects.
A buffer's ownership count starts at 1.
public final int getOwnerCount()
public final void dispose()
This method should be invoked by the user when done with an IO buffer. It decrements the buffer's ownership count and releases it to its object pool (if one is tagged to it) and this method causes the ownership count to reduce to zero. If not tagged to a pool, ownership change methods have no side effects aside from just updating the ownership counter.
Upon return from this method, the caller should assume that the buffer has been disposed and release its reference to the buffer.
public final PktIOBuffer init()
init
in interface com.neeve.util.UtlPool.Item<PktIOBuffer>
public final PktIOBuffer setPool(com.neeve.util.UtlPool<PktIOBuffer> pool)
setPool
in interface com.neeve.util.UtlPool.Item<PktIOBuffer>
public final com.neeve.util.UtlPool<PktIOBuffer> getPool()
getPool
in interface com.neeve.util.UtlPool.Item<PktIOBuffer>
public final com.neeve.util.UtlReferenceTracker referenceTracker()
referenceTracker
in interface com.neeve.util.UtlReferenceTracker.HasReferenceTracker
public final String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |