Top Description Fields Constructors Methods
io.netty5.channel.unix

public final Class IovArray

extends Object
implements Predicate<Object>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate
Imports
io.netty5.buffer.Buffer, .BufferComponent, io.netty5.util.internal.PlatformDependent, java.nio.ByteBuffer, .ByteOrder, java.util.function.Predicate

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

Modifier and TypeField and Description
private static final int
ADDRESS_SIZE

The size of an address which should be 8 for 64 bits and 4 for 32 bits.

private int
public static final int
IOV_SIZE

The size of an iovec struct in bytes.

private static final int
MAX_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 long
private final ByteBuffer
private final long
private long

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private boolean
add(long memoryAddress, long addr, int len)

public boolean
public boolean
addReadable(BufferComponent component, int byteCount)

public boolean
public boolean
addWritable(BufferComponent component, int byteCount)

public void
public int
count()

Returns the number if iov entries.

private static int
idx(int index)

public void
maxBytes(long
the maximum amount of bytes that can be added to this IovArray.
maxBytes
)

Set the maximum amount of bytes that can be added to this IovArray via add(long, long, int) or test(Object).

public long

Returns:

the maximum amount of bytes that can be added to this IovArray.
maxBytes
()

Get the maximum amount of bytes that can be added to this IovArray.

public long
memoryAddress(int index)

Returns the memoryAddress for the given index.

public void
release()

Release the IovArray.

public long
size()

Returns the size in bytes

public boolean
test(Object
the input argument
msg
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.
public int

Returns:

the number of messages that are totally written for the given number of total bytes.
writtenMessages
(int
the start index.
index
,
long
the total number of bytes
totalBytes
)

Return the number of messages that have been completely written for the given total number of bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ADDRESS_SIZEback to summary
private static final int ADDRESS_SIZE

The size of an address which should be 8 for 64 bits and 4 for 32 bits.

countback to summary
private int count
IOV_SIZEback to summary
public static final int IOV_SIZE

The size of an iovec struct in bytes. This is calculated as we have 2 entries each of the size of the address.

MAX_CAPACITYback to summary
private static final int MAX_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(...).

maxBytesback to summary
private long maxBytes
memoryback to summary
private final ByteBuffer memory
memoryAddressback to summary
private final long memoryAddress
sizeback to summary
private long size

Constructor Detail

IovArrayback to summary
public IovArray()
IovArrayback to summary
public IovArray(ByteBuffer memory)

Method Detail

addback to summary
private boolean add(long memoryAddress, long addr, int len)
addReadableback to summary
public boolean addReadable(Buffer buffer)
addReadableback to summary
public boolean addReadable(BufferComponent component, int byteCount)
addWritableback to summary
public boolean addWritable(Buffer buffer)
addWritableback to summary
public boolean addWritable(BufferComponent component, int byteCount)
clearback to summary
public void clear()
countback to summary
public int count()

Returns the number if iov entries.

idxback to summary
private static int idx(int index)
maxBytesback to summary
public void maxBytes(long maxBytes)

Set the maximum amount of bytes that can be added to this IovArray via add(long, long, int) or test(Object).

This will not impact the existing state of the IovArray, and only applies to subsequent calls to add(long, long, int) or test(Object).

In order to ensure some progress is made at least one Buffer will be accepted even if it's size exceeds this value.

Parameters
maxBytes:long

the maximum amount of bytes that can be added to this IovArray.

maxBytesback to summary
public long maxBytes()

Get the maximum amount of bytes that can be added to this IovArray.

Returns:long

the maximum amount of bytes that can be added to this IovArray.

memoryAddressback to summary
public long memoryAddress(int index)

Returns the memoryAddress for the given index.

releaseback to summary
public void release()

Release the IovArray. Once release further using of it may crash the JVM!

sizeback to summary
public long size()

Returns the size in bytes

testback to summary
public boolean test(Object msg)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
msg:Object

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override
writtenMessagesback to summary
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:int

the start index.

totalBytes:long

the total number of bytes

Returns:int

the number of messages that are totally written for the given number of total bytes.