Class DefaultMaxMessagesRecvByteBufAllocator

java.lang.Object
io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
All Implemented Interfaces:
MaxMessagesRecvByteBufAllocator, RecvByteBufAllocator
Direct Known Subclasses:
AdaptiveRecvByteBufAllocator, FixedRecvByteBufAllocator, ServerChannelRecvByteBufAllocator

public abstract class DefaultMaxMessagesRecvByteBufAllocator extends Object implements MaxMessagesRecvByteBufAllocator
Default implementation of MaxMessagesRecvByteBufAllocator which respects ChannelConfig.isAutoRead() and also prevents overflow.
  • Field Details

    • ignoreBytesRead

      private final boolean ignoreBytesRead
    • maxMessagesPerRead

      private volatile int maxMessagesPerRead
    • respectMaybeMoreData

      private volatile boolean respectMaybeMoreData
  • Constructor Details

    • DefaultMaxMessagesRecvByteBufAllocator

      public DefaultMaxMessagesRecvByteBufAllocator()
    • DefaultMaxMessagesRecvByteBufAllocator

      public DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead)
    • DefaultMaxMessagesRecvByteBufAllocator

      DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead, boolean ignoreBytesRead)
  • Method Details

    • maxMessagesPerRead

      public int maxMessagesPerRead()
      Description copied from interface: MaxMessagesRecvByteBufAllocator
      Returns the maximum number of messages to read per read loop. a channelRead() event. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.
      Specified by:
      maxMessagesPerRead in interface MaxMessagesRecvByteBufAllocator
    • maxMessagesPerRead

      public MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int maxMessagesPerRead)
      Description copied from interface: MaxMessagesRecvByteBufAllocator
      Sets the maximum number of messages to read per read loop. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.
      Specified by:
      maxMessagesPerRead in interface MaxMessagesRecvByteBufAllocator
    • respectMaybeMoreData

      public DefaultMaxMessagesRecvByteBufAllocator respectMaybeMoreData(boolean respectMaybeMoreData)
      Determine if future instances of RecvByteBufAllocator.newHandle() will stop reading if we think there is no more data.
      Parameters:
      respectMaybeMoreData -
      • true to stop reading if we think there is no more data. This may save a system call to read from the socket, but if data has arrived in a racy fashion we may give up our maxMessagesPerRead() quantum and have to wait for the selector to notify us of more data.
      • false to keep reading (up to maxMessagesPerRead()) or until there is no data when we attempt to read.
      Returns:
      this.
    • respectMaybeMoreData

      public final boolean respectMaybeMoreData()
      Get if future instances of RecvByteBufAllocator.newHandle() will stop reading if we think there is no more data.
      Returns:
      • true to stop reading if we think there is no more data. This may save a system call to read from the socket, but if data has arrived in a racy fashion we may give up our maxMessagesPerRead() quantum and have to wait for the selector to notify us of more data.
      • false to keep reading (up to maxMessagesPerRead()) or until there is no data when we attempt to read.