- java.lang.Object
-
- io.netty5.channel.unix.IovArray
-
- All Implemented Interfaces:
ReadableComponentProcessor<RuntimeException>,WritableComponentProcessor<RuntimeException>,ChannelOutboundBuffer.MessageProcessor
public final class IovArray extends Object implements ChannelOutboundBuffer.MessageProcessor, ReadableComponentProcessor<RuntimeException>, WritableComponentProcessor<RuntimeException>
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 alsoman 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 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)orprocessMessage(Object).longmemoryAddress(int index)Returns thememoryAddressfor the givenindex.booleanprocess(int index, ReadableComponent component)Process the given component at the given index in theiteration.booleanprocess(int index, WritableComponent component)Process the given component at the given index in theBuffer.forEachWritable(int, WritableComponentProcessor)iteration}.booleanprocess(ReadableComponent component, int byteCount)booleanprocess(WritableComponent component, int byteCount)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
-
-
-
Constructor Detail
-
IovArray
public IovArray()
-
IovArray
public IovArray(ByteBuffer memory)
-
-
Method Detail
-
clear
public void clear()
-
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)orprocessMessage(Object).This will not impact the existing state of the
IovArray, and only applies to subsequent calls toadd(long, long, int)orprocessMessage(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!
-
processMessage
public boolean processMessage(Object msg)
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
-
process
public boolean process(int index, ReadableComponent component)Description copied from interface:ReadableComponentProcessorProcess the given component at the given index in theiteration.The component object itself is only valid during this call, but the
byte buffers, arrays, and native address pointers obtained from it, will be valid until any operation is performed on the buffer, which changes the internal memory.- Specified by:
processin interfaceReadableComponentProcessor<RuntimeException>- Parameters:
index- The current index of the given buffer component, based on the initial index passed to theBuffer.forEachReadable(int, ReadableComponentProcessor)method.component- The current buffer component being processed.- Returns:
trueif the iteration should continue and more components should be processed, otherwisefalseto stop the iteration early.
-
process
public boolean process(ReadableComponent component, int byteCount)
-
process
public boolean process(int index, WritableComponent component)Description copied from interface:WritableComponentProcessorProcess the given component at the given index in theBuffer.forEachWritable(int, WritableComponentProcessor)iteration}.The component object itself is only valid during this call, but the
byte buffers, arrays, and native address pointers obtained from it, will be valid until anyownershiprequiring operation is performed on the buffer.- Specified by:
processin interfaceWritableComponentProcessor<RuntimeException>- Parameters:
index- The current index of the given buffer component, based on the initial index passed to theBuffer.forEachWritable(int, WritableComponentProcessor)method.component- The current buffer component being processed.- Returns:
trueif the iteration should continue and more components should be processed, otherwisefalseto stop the iteration early.
-
process
public boolean process(WritableComponent component, int byteCount)
-
-