Class Runtime
java.lang.Object
com.github.kaktushose.jda.commands.dispatching.Runtime
- All Implemented Interfaces:
Closeable,AutoCloseable
A Runtime delegates the jda events to their corresponding EventHandler and manages the used virtual threads.
A new Runtime is created each time an SlashCommandInteractionEvent, GenericContextInteractionEvent or CommandAutoCompleteInteractionEvent is provided by jda
or if an interaction is marked as 'independent'.
Runtimes are executed in parallel, but events are processed sequentially by each runtime.
Every EventHandler called by this Runtime is executed in its own virtual thread, isolated from the runtime one.
- Implementation Note:
- Each
Runtimeis based on aBlockingQueuein which jda events, belonging to this runtime, are put by theJDAEventListenerrunning on the jda event thread. Each runtime than has its own virtual thread that takes events from this queue and executes them sequentially but each in its own (sub) virtual thread. Therefore, the virtual thread in which the user code will be called, only exists for the lifespan of one "interaction" and cannot interfere with other interactions on the same or other runtimes.
-
Method Details
-
startNew
-
id
-
queueEvent
-
keyValueStore
-
i18n
-
messageResolver
-
interactionInstance
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed()
-