Class IovArray
java.lang.Object
io.netty.channel.unix.IovArray
- All Implemented Interfaces:
ChannelOutboundBuffer.MessageProcessor
Represent an array of struct array and so can be passed directly over via JNI without the need to do any more
array copies.
The buffers are written out directly into direct memory to match the struct iov. See also
man writev.
struct iovec {
void *iov_base;
size_t iov_len;
};
See also
Efficient JNI programming IV: Wrapping native data objects.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIovArray()Deprecated.IovArray(int numEntries) Allocate an IovArray with enough room for the given number of entries (not bytes).Deprecated.UseIovArray(int)instead. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.booleanvoidclear()intcount()Returns the number if iov entries.booleanisFull()Returntrueif there is no more space left in theIovArray.longmaxBytes()Get the maximum amount of bytes that can be added to thisIovArray.voidmaxBytes(long maxBytes) Set the maximum amount of bytes that can be added to thisIovArrayviaadd(ByteBuf, int, int)intmaxCount()Get the maximum amount of buffers that can be added to thisIovArray.voidmaxCount(int maxCount) Set the maximum amount of buffers that can be added to thisIovArrayviaadd(ByteBuf, int, int)longmemoryAddress(int offset) Returns thememoryAddressfor the givenoffset.booleanprocessMessage(Object msg) Will be called for each flushed message until it either there are no more flushed messages or this method returnsfalse.voidrelease()Release theIovArray.longsize()Returns the size in bytes
-
Field Details
-
IOV_SIZE
public static final int IOV_SIZEThe size of aniovecstruct in bytes. This is calculated as we have 2 entries each of the size of the address.
-
-
Constructor Details
-
IovArray
Deprecated.UseIovArray(int)instead. -
IovArray
public IovArray(int numEntries) Allocate an IovArray with enough room for the given number of entries (not bytes).- Parameters:
numEntries- The desired number of entries in the IovArray.
-
IovArray
Deprecated.UseIovArray(int)instead.- Parameters:
memory- The underlying memory.
-
-
Method Details
-
clear
public void clear() -
add
Deprecated. -
add
-
isFull
public boolean isFull()Returntrueif there is no more space left in theIovArray.- Returns:
- full or not.
-
count
public int count()Returns the number if iov entries. -
size
public long size()Returns the size in bytes -
maxBytes
public void maxBytes(long maxBytes) Set the maximum amount of bytes that can be added to thisIovArrayviaadd(ByteBuf, int, int)This will not impact the existing state of the
IovArray, and only applies to subsequent calls toadd(ByteBuf).In order to ensure some progress is made at least one
ByteBufwill be accepted even if it's size exceeds this value.- Parameters:
maxBytes- the maximum amount of bytes that can be added to thisIovArray.
-
maxCount
public void maxCount(int maxCount) Set the maximum amount of buffers that can be added to thisIovArrayviaadd(ByteBuf, int, int)This will not impact the existing state of the
IovArray, and only applies to subsequent calls toadd(ByteBuf).- Parameters:
maxCount- the maximum amount of bytes that can be added to thisIovArray.
-
maxBytes
-
maxCount
-
memoryAddress
public long memoryAddress(int offset) Returns thememoryAddressfor the givenoffset. -
release
public void release()Release theIovArray. Once release further using of it may crash the JVM! -
processMessage
Description copied from interface:ChannelOutboundBuffer.MessageProcessorWill be called for each flushed message until it either there are no more flushed messages or this method returnsfalse.- Specified by:
processMessagein interfaceChannelOutboundBuffer.MessageProcessor- Throws:
Exception
-
IovArray(int)instead.