- java.lang.Object
-
- io.netty5.channel.unix.IovArray
-
public final class IovArray extends Object implements Predicate<Object>
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 Modifier and Type Field Description static intIOV_SIZEThe size of aniovecstruct in bytes.
-
Constructor Summary
Constructors Constructor Description IovArray()IovArray(ByteBuffer memory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddReadable(io.netty5.buffer.Buffer buffer)booleanaddReadable(io.netty5.buffer.BufferComponent component, int byteCount)booleanaddWritable(io.netty5.buffer.Buffer buffer)booleanaddWritable(io.netty5.buffer.BufferComponent component, int byteCount)voidclear()intcount()Returns the number if iov entries.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(long, long, int)ortest(Object).longmemoryAddress(int index)Returns thememoryAddressfor the givenindex.voidrelease()Release theIovArray.longsize()Returns the size in bytesbooleantest(Object msg)intwrittenMessages(int index, long totalBytes)Return the number of messages that have been completely written for the given total number of bytes.
-
-
-
Constructor Detail
-
IovArray
public IovArray()
-
IovArray
public IovArray(ByteBuffer memory)
-
-
Method Detail
-
clear
public void clear()
-
writtenMessages
public int writtenMessages(int index, long totalBytes)Return the number of messages that have been completely written for the given total number of bytes.- Parameters:
index- the start index.totalBytes- the total number of bytes- Returns:
- the number of messages that are totally written for the given number of total bytes.
-
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(long, long, int)ortest(Object).This will not impact the existing state of the
IovArray, and only applies to subsequent calls toadd(long, long, int)ortest(Object).In order to ensure some progress is made at least one
Bufferwill be accepted even if it's size exceeds this value.- Parameters:
maxBytes- the maximum amount of bytes that can be added to thisIovArray.
-
maxBytes
public long maxBytes()
Get the maximum amount of bytes that can be added to thisIovArray.- Returns:
- the maximum amount of bytes that can be added to this
IovArray.
-
memoryAddress
public long memoryAddress(int index)
Returns thememoryAddressfor the givenindex.
-
release
public void release()
Release theIovArray. Once release further using of it may crash the JVM!
-
addReadable
public boolean addReadable(io.netty5.buffer.Buffer buffer)
-
addReadable
public boolean addReadable(io.netty5.buffer.BufferComponent component, int byteCount)
-
addWritable
public boolean addWritable(io.netty5.buffer.Buffer buffer)
-
addWritable
public boolean addWritable(io.netty5.buffer.BufferComponent component, int byteCount)
-
-