public class OnDemandEventLoop extends Object implements EventLoop
EventLoop which is created on demand when any of its methods are called.
This can be used to lazily instantiate an EventLoop only when it's actually needed.
DEBUG_ADDING_HANDLERS| Constructor and Description |
|---|
OnDemandEventLoop(@NotNull Supplier<EventLoop> eventLoopSupplier)
Constructs an OnDemandEventLoop with the given supplier for creating the actual EventLoop.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(EventHandler handler)
Adds a handler to the event loop to be executed.
|
void |
close()
Closes the EventLoop if it has been created.
|
boolean |
hasEventLoop()
Checks if the EventLoop has been created.
|
boolean |
isAlive()
Checks if the main thread of the event loop is running.
|
boolean |
isClosed()
Checks if this object is closed.
|
boolean |
isStopped()
Checks if the event loop is in the stopped state.
|
String |
name()
Retrieves the name of the event loop.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinEventLoop, runsInsideCoreLoopcloseQuietly, closeQuietlyisClosingpublic boolean hasEventLoop()
public String name()
EventLooppublic void addHandler(EventHandler handler)
EventLoopEventLoop.start()
has been called.addHandler in interface EventLoophandler - The handler to be added to the event loop.public void start()
EventLooppublic void unpause()
EventLooppublic void stop()
EventLooppublic boolean isClosed()
QueryCloseableisClosed in interface QueryCloseableclose() method has completed, false otherwisepublic boolean isAlive()
EventLooppublic boolean isStopped()
EventLooppublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface EventLoopAbstractCloseable.performClose()Copyright © 2024. All rights reserved.