@FunctionalInterface public interface EventHandler extends VanillaEventHandler
Modifier and Type | Method and Description |
---|---|
default void |
eventLoop(EventLoop eventLoop)
This method is called once when it is added to an eventLoop, which might be before the EventLoop has started
This could be called in any thread.
|
default void |
loopFinished()
Notify handler that the event the handler's action method
will not be called again.
|
default void |
loopStarted()
This handler has been added to an EventLoop or when the EventLoop starts.
|
default HandlerPriority |
priority() |
action
default void eventLoop(EventLoop eventLoop)
eventLoop
- the handler has been added to.default void loopStarted()
default void loopFinished()
This is called either when the event loop is terminating, or if this EventHandler is being removed from the event loop.
If this implements Closeable
then the event loop will call close (once only) on this after
loopFinished has been called.
If this implements Closeable
and something other than the event loop
calls close then it is expected that this will throw InvalidEventHandlerException
next time
VanillaEventHandler.action()
is called. This will then allow the event loop to call loopFinished (and close) on this.
If this use case is required it is strongly recommend that this event handler guards against close
being called more than once (and ignores subsequent calls).
Exceptions thrown by loopFinished or close are caught and logged (at debug level) and cleanup continues.
@NotNull default HandlerPriority priority()
Copyright © 2020. All rights reserved.