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
Native.IOV_MAX iov entries, where Native.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 |
---|---|
(package private) boolean |
add(ByteBuf buf)
Try to add the given
ByteBuf . |
(package private) boolean |
add(CompositeByteBuf buf)
Try to add the given
CompositeByteBuf . |
private boolean |
add(long addr,
int offset,
int len) |
(package private) void |
clear() |
(package private) int |
count()
Returns the number if iov entries.
|
(package private) 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 . |
(package private) long |
processWritten(int index,
long written)
Process the written iov entries.
|
(package private) void |
release()
Release the
IovArray . |
(package private) 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
Native.IOV_MAX
iov entries, where Native.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
void clear()
boolean add(ByteBuf buf)
private boolean add(long addr, int offset, int len)
boolean add(CompositeByteBuf buf)
long processWritten(int index, long written)
written
value. Otherwise it returns -1
.int count()
long size()
long memoryAddress(int offset)
memoryAddress
for the given offset
.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