|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.io.IOElasticBuffer
com.neeve.pkt.PktBuffer
public final class PktBuffer
Implements the buffer that backs a packet header or body.
A packet buffer serves as the backing buffer of a packet header or body. It
maintains a view into an underlying IOBuffer
. It holds an instance
of a IOBuffer
object and an offset and length that defines its
window into the underlying buffer. It support 'copy on write' and 'fail on
write' semantics.
A user supplied an instance of IOElasticBuffer.Sizer
when creating
a new packet buffer. The sizer is queried by the buffer for the entity's
serialized length when it needs to create a new IO buffer. This is done
implicitly by the putXXX/getXXX methods if an IO buffer has not already
been created or supplied by the user via IOElasticBuffer.wrapIOBuffer(com.neeve.io.IOBuffer, int, int)
.
The reason why a user needs to specify whether the underlying buffer is being
obtained for read or write is to to support 'copy on write' and 'fail on write'
semantics. The IOElasticBuffer.setCopyOnWrite()
and IOElasticBuffer.setFailOnWrite()
methods mark
the packet buffer as 'copy on write' and 'fail on write' respectively. A buffer
marked as 'copy on write' will cause the next call to modify the length or contents
of the underlying buffer to 'clone' the underlying buffer before performing the
operation on it.
IOBuffer
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.Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.neeve.io.IOElasticBuffer |
---|
com.neeve.io.IOElasticBuffer.Initializer, com.neeve.io.IOElasticBuffer.Sizer |
Method Summary | |
---|---|
static PktBuffer |
create(com.neeve.io.IOElasticBuffer.Sizer owner,
int bufferLength,
boolean isNative)
Create a new packet buffer |
static PktBuffer |
create(PktSerializable owner,
int bufferLength,
boolean isNative)
Deprecated. This method has been deprecated in favor of IOElasticBuffer.create(Sizer, int, boolean) |
Methods inherited from class com.neeve.io.IOElasticBuffer |
---|
calculateUTFLength, calculateUTFLength, clearCopyOnWrite, clearFailOnWrite, dump, ensureBackingBufferExists, fork, get, getByteOrder, getChar, getDouble, getFloat, getInitializer, getInt, getIOBuffer, getIOBufferForRead, getIOBufferForWrite, getLength, getLong, getOffset, getResumptionLength, getShort, getString, getTo, getTo, getTo, getTo, getTo, getTo, getTo, getTo, getTo, getTo, getToNative, getUnsignedByte, getUnsignedInt, getUnsignedShort, inputStream, isCopyOnWrite, isFailOnWrite, isNative, isResizeNeededFor, outputStream, put, putChar, putCharSequenceUTF, putCharUTF8, putDouble, putFloat, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFrom, putFromNative, putInt, putLong, putShort, putString, reset, setByteOrder, setCopyOnWrite, setFailOnWrite, setInitializer, setLength, toString, wipe, wrapIOBuffer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static PktBuffer create(com.neeve.io.IOElasticBuffer.Sizer owner, int bufferLength, boolean isNative)
owner
- The owner of the packet bufferbufferLength
- The length of the backing buffer. If <=0, the
packet buffer will query the owner for the size.isNative
- Whether the backing IO buffer should be native or not
@Deprecated public static PktBuffer create(PktSerializable owner, int bufferLength, boolean isNative)
IOElasticBuffer.create(Sizer, int, boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |