public interface EventLoop extends Closeable
EventHandlers.
Implementations are not re-entrant. All state changes must occur on
the event-loop thread to avoid race conditions. Typical usage is to add
handlers before calling start() and then interact with the loop only
from within its own thread.
The runsInsideCoreLoop() method allows callers to detect if the
current thread is the core event thread. Code already running on the loop can
call handlers directly rather than using an invokeAndWait-style
mechanism.
Calling addHandler(EventHandler) after stop() results in an
IllegalStateException.
Handler priorities control the relative frequency of
handler invocation. The following table shows the approximate call frequency
compared with HIGH priority:
Priority Relative frequency HIGH 1 (baseline) MEDIUM ~1/4 of HIGH TIMER ~1/16 of HIGH DAEMON only when idle MONITOR background thread BLOCKING separate cached thread pool REPLICATION alias of MEDIUM REPLICATION_TIMER alias of TIMER CONCURRENT alias of MEDIUM
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG_ADDING_HANDLERS |
static boolean |
DEBUG_REMOVING_HANDLERS |
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(EventHandler handler)
Adds a handler to the event loop to be executed.
|
void |
close()
Stops the event loop and then closes any resources being held.
|
static boolean |
inEventLoop()
Checks if the current thread is executing inside an event loop.
|
boolean |
isAlive()
Checks if the main thread of the event loop is running.
|
boolean |
isStopped()
Checks if the event loop is in the stopped state.
|
String |
name()
Retrieves the name of the event loop.
|
default boolean |
runsInsideCoreLoop()
Checks if the current thread is the core thread of this event loop, or if this information
cannot be determined.
|
void |
start()
Starts the event loop.
|
void |
stop()
Stops executing handlers and blocks until all handlers are complete.
|
void |
unpause()
Typically, implementations will unpause the event loop's pauser, if used.
|
closeQuietly, closeQuietlyisClosed, isClosingstatic final boolean DEBUG_ADDING_HANDLERS
static final boolean DEBUG_REMOVING_HANDLERS
String name()
void addHandler(EventHandler handler)
start()
has been called.handler - The handler to be added to the event loop.IllegalStateException - if the event loop has been stopped
or closed.void start()
void unpause()
void stop()
boolean isAlive()
true if the main thread is running, otherwise false.boolean isStopped()
true if the event loop is in the stopped state, otherwise false.static boolean inEventLoop()
true if the current thread is executing inside an event loop, otherwise false.void close()
close in interface AutoCloseableclose in interface CloseableAbstractCloseable.performClose()default boolean runsInsideCoreLoop()
false.true unless the current thread is not the core event thread.Copyright © 2026 Chronicle Software Ltd. All rights reserved.