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

public final Class IovArray

extends Object
implements MessageProcessor
Class Inheritance
All Implemented Interfaces
io.netty.channel.ChannelOutboundBuffer.MessageProcessor
Imports
io.netty.buffer.ByteBuf, .Unpooled, io.netty.channel.ChannelOutboundBuffer.MessageProcessor, io.netty.util.internal.PlatformDependent, java.nio.ByteBuffer, .ByteOrder

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 ByteBuf
private final long
private long

Constructor Summary

AccessConstructor and Description
public
public
IovArray(ByteBuf memory)

Method Summary

Modifier and TypeMethod and Description
public boolean
add(ByteBuf buf)

Deprecated Use add(ByteBuf, int, int)
public boolean
add(ByteBuf buf, int offset, int len)

private boolean
add(long memoryAddress, long addr, int len)

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(ByteBuf, int, int)

This will not impact the existing state of the IovArray, and only applies to subsequent calls to add(ByteBuf).

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 offset)

Returns the memoryAddress for the given offset.

public boolean
processMessage(Object msg)

Implements io.netty.channel.ChannelOutboundBuffer.MessageProcessor.processMessage.

Will be called for each flushed message until it either there are no more flushed messages or this method returns false.
public void
release()

Release the IovArray.

public long
size()

Returns the size in 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 ByteBuf 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(ByteBuf memory)
Annotations
@SuppressWarnings:deprecation

Method Detail

addback to summary
public boolean add(ByteBuf buf)

Deprecated

Use add(ByteBuf, int, int)

Annotations
@Deprecated
addback to summary
public boolean add(ByteBuf buf, int offset, int len)
addback to summary
private boolean add(long memoryAddress, long addr, int len)
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(ByteBuf, int, int)

This will not impact the existing state of the IovArray, and only applies to subsequent calls to add(ByteBuf).

In order to ensure some progress is made at least one ByteBuf 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 offset)

Returns the memoryAddress for the given offset.

processMessageback to summary
public boolean processMessage(Object msg) throws Exception

Implements io.netty.channel.ChannelOutboundBuffer.MessageProcessor.processMessage.

Doc from io.netty.channel.ChannelOutboundBuffer.MessageProcessor.processMessage.

Will be called for each flushed message until it either there are no more flushed messages or this method returns false.

Annotations
@Override
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