Class EventBase<T>

Type Parameters:
T - the result type of the event. Use Void if handling the event does not produce a result
All Implemented Interfaces:
Future<T>, Associator, Eligible
Direct Known Subclasses:

public abstract class EventBase<T> extends Object implements Eligible, Future<T>, Associator
Provides the implementations of methods to class Event that need access to classes or methods that are visible in the implementation package only.

The class is not intended to be used as base class for any other class.

  • Field Details

    • completionEvents

      protected Set<Event<?>> completionEvents
      The events to be fired upon completion.

      Using this attribute provides a slightly faster access than invoking Event.completionEvents(), which wraps the result in an unmodifiable set.

    • completed

      protected boolean completed
      Set when the event has been completed.
  • Constructor Details

  • Method Details

    • channels

      public abstract Channel[] channels()
      the channel[]
    • handled

      protected abstract void handled()
    • isStopped

      public abstract boolean isStopped()
    • currentResults

      protected abstract List<T> currentResults()
    • setRequiresResult

      protected EventBase<T> setRequiresResult(boolean value)
    • firstResultAssigned

      protected void firstResultAssigned()
    • enqueued

      protected boolean enqueued()
      Returns true if the event has been enqueued in a pipeline.
      the result
    • handlingError

      protected abstract void handlingError(EventPipeline eventProcessor, Throwable throwable)
      Invoked when an exception occurs while invoking a handler for an event.
      eventProcessor - the manager that has invoked the handler
      throwable - the exception that has been thrown by the handler
    • processedBy

    • suspendHandling

      public void suspendHandling()
      Suspend the invocation of the remaining handlers for this event.

      May only be called in a handler for the event. Must be balanced by an invocation of resumeHandling().

    • suspendHandling

      public void suspendHandling(Runnable whenResumed)
      Suspend the invocation of the remaining handlers for this event.

      May only be called in a handler for the event. Must be balanced by an invocation of resumeHandling().

      whenResumed - some function to be executed when handling is resumed
    • resumeHandling

      public void resumeHandling()
      Resume the invocation of handlers for this event.
      See Also:
    • disableTracking

      public Event<T> disableTracking()
      Disables tracking for this event and all events generated when handling it.
    • isTracked

      public boolean isTracked()
      Whether the event (and all events generated when handling it) is tracked.
      true if event is tracked
    • addCompletionEvent

      public abstract Event<T> addCompletionEvent(Event<?> completionEvent)
      Adds the given event to the events to be thrown when this event has completed (see Future.isDone()).

      Such an event is called a “completion event”.

      Completion events are considered to be caused by the event that caused the completed event. If an event e1 caused an event e2 which has a completion event e2c, e1 is only put in state completed when e2c has been handled.

      Completion events are handled by the same EventProcessor as the event that has been completed.

      completionEvent - the completion event to add
      the object for easy chaining
      See Also:
    • onCompletion

      public static <T, E extends Event<T>> E onCompletion(E event, Consumer<E> consumer)
      Invokes the consumer when the event is completed.

      This is a shortcut for registering a CompletionEvent and providing a handler for the completion event that invokes the consumer.

      The static form is required because otherwise the compiler cannot infer the type of the consumer’s argument.

      Type Parameters:
      T - the result type of the event
      E - the type of the event
      event - the event
      consumer - the consumer
      the event