public final class IovArray extends java.lang.Object implements ChannelOutboundBuffer.MessageProcessor
man writev
.
struct iovec { void *iov_base; size_t iov_len; };See also Efficient JNI programming IV: Wrapping native data objects.
Modifier and Type | Field and Description |
---|---|
private static int |
ADDRESS_SIZE
The size of an address which should be 8 for 64 bits and 4 for 32 bits.
|
private static int |
CAPACITY
The needed memory to hold up to
IOV_MAX iov entries, where IOV_MAX signified
the maximum number of iovec structs that can be passed to writev(...) . |
private int |
count |
private static int |
IOV_SIZE
The size of an
iovec struct in bytes. |
private long |
memoryAddress |
private long |
size |
Constructor and Description |
---|
IovArray() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(ByteBuf buf)
Try to add the given
ByteBuf . |
private boolean |
add(long addr,
int offset,
int len) |
void |
clear() |
int |
count()
Returns the number if iov entries.
|
long |
memoryAddress(int offset)
Returns the
memoryAddress for the given offset . |
boolean |
processMessage(java.lang.Object msg)
Will be called for each flushed message until it either there are no more flushed messages or this
method returns
false . |
long |
processWritten(int index,
long written)
Process the written iov entries.
|
void |
release()
Release the
IovArray . |
long |
size()
Returns the size in bytes
|
private static final int ADDRESS_SIZE
private static final int IOV_SIZE
iovec
struct in bytes. This is calculated as we have 2 entries each of the size of the
address.private static final int CAPACITY
IOV_MAX
iov entries, where IOV_MAX
signified
the maximum number of iovec
structs that can be passed to writev(...)
.private final long memoryAddress
private int count
private long size
public void clear()
public boolean add(ByteBuf buf)
private boolean add(long addr, int offset, int len)
public long processWritten(int index, long written)
written
value. Otherwise it returns -1
.public int count()
public long size()
public long memoryAddress(int offset)
memoryAddress
for the given offset
.public void release()
IovArray
. Once release further using of it may crash the JVM!public boolean processMessage(java.lang.Object msg) throws java.lang.Exception
ChannelOutboundBuffer.MessageProcessor
false
.processMessage
in interface ChannelOutboundBuffer.MessageProcessor
java.lang.Exception