Class IovArray

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int ADDRESS_SIZE
      The size of an address which should be 8 for 64 bits and 4 for 32 bits.
      private int count  
      static int IOV_SIZE
      The size of an iovec struct in bytes.
      private static 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 maxBytes  
      private ByteBuf memory  
      private long memoryAddress  
      private long size  
    • Field Detail

      • ADDRESS_SIZE

        private static final int ADDRESS_SIZE
        The size of an address which should be 8 for 64 bits and 4 for 32 bits.
      • IOV_SIZE

        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_CAPACITY

        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(...).
      • memoryAddress

        private final long memoryAddress
      • memory

        private final ByteBuf memory
      • count

        private int count
      • size

        private long size
      • maxBytes

        private long maxBytes
    • Constructor Detail

      • IovArray

        public IovArray()
      • IovArray

        public IovArray​(ByteBuf memory)
    • Method Detail

      • clear

        public void clear()
      • add

        public boolean add​(ByteBuf buf,
                           int offset,
                           int len)
      • add

        private boolean add​(long memoryAddress,
                            long addr,
                            int len)
      • 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 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 - the maximum amount of bytes that can be added to this IovArray.
      • maxBytes

        public long maxBytes()
        Get the maximum amount of bytes that can be added to this IovArray.
        Returns:
        the maximum amount of bytes that can be added to this IovArray.
      • memoryAddress

        public long memoryAddress​(int offset)
        Returns the memoryAddress for the given offset.
      • release

        public void release()
        Release the IovArray. Once release further using of it may crash the JVM!
      • idx

        private static int idx​(int index)