Class IOEvent<T extends Buffer>

Type Parameters:
T - the type of data used in this event
All Implemented Interfaces:
Future<Void>, Associator, Eligible
Direct Known Subclasses:
Input, Output

public abstract class IOEvent<T extends Buffer> extends Event<Void>
Events of this type signal that a new chunk of data is available for processing.

From a consumer’s point of view, the data is kept in a NIO Buffer. However, when creating the event the data has to be provided as a ManagedBuffer. This buffer is returned to the pool upon successful processing of the event.

As a convenience, the class provides the methods known from Buffer as short-cuts for invoking data().method().

  • Constructor Details

    • IOEvent

      protected IOEvent(ManagedBuffer<T> buffer, boolean endOfRecord)
      Instantiates a new IO event.
      Parameters:
      buffer - the buffer
      endOfRecord - the end of record
  • Method Details

    • buffer

      public ManagedBuffer<T> buffer()
      Get the managed buffer with the data from this event.
      Returns:
      the buffer
    • data

      public T data()
      Return the data associated with this event as Buffer.

      This is short for buffer().backingBuffer().

      Returns:
      the data
    • isEndOfRecord

      public boolean isEndOfRecord()
      Return the end of record flag passed to the constructor.

      The precise interpretation of a record depends on the data handled.

      Returns:
      the end of record flag
    • handled

      protected void handled()
      Description copied from class: Event
      Invoked after all handlers for the event have been executed.

      May be overridden by derived classes to cause some immediate effect (instead of e.g. waiting for the completion event). The default implementation does nothing. This method is invoked by the event handler thread and must not block.

      Overrides:
      handled in class Event<Void>
    • toString

      public String toString()
      Overrides:
      toString in class Event<Void>
    • hasRemaining

      public final boolean hasRemaining()
      Returns:
      the result
      See Also:
    • remaining

      public final int remaining()
      Returns:
      the result
      See Also: