Klasse DbExecutor
java.lang.Object
de.delinkedde.mobarenareborn.persistence.DbExecutor
The single background thread all database work is serialised onto.
SQLite connections must not be used concurrently; funnelling every read and write of every
service through this one thread guarantees ordered access without locking and keeps the main
server thread free of I/O. shutdown() drains pending work before the connection is
closed.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidRuns a task on the database thread; falls back to the calling thread when the executor is already shutting down (so final flushes still complete).voidshutdown()Drains and stops the executor.<T> @NotNull Future<T> Submits a value-returning task to the database thread.
-
Konstruktordetails
-
DbExecutor
- Parameter:
plugin- the owning plugin, used for logging
-
-
Methodendetails
-
execute
Runs a task on the database thread; falls back to the calling thread when the executor is already shutting down (so final flushes still complete).- Parameter:
task- the task to run
-
submit
Submits a value-returning task to the database thread.- Typparameter:
T- the result type- Parameter:
task- the task to submit- Gibt zurück:
- a future completing with the task's result
-
shutdown
public void shutdown()Drains and stops the executor. Call once during plugin shutdown, before the database connection is closed, so all pending writes complete first.
-