Klasse DbExecutor

java.lang.Object
de.delinkedde.mobarenareborn.persistence.DbExecutor

public final class DbExecutor extends Object
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.

  • Konstruktordetails

    • DbExecutor

      public DbExecutor(@NotNull @NotNull MobArenaPlugin plugin)
      Parameter:
      plugin - the owning plugin, used for logging
  • Methodendetails

    • execute

      public void execute(@NotNull @NotNull Runnable task)
      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

      @NotNull public <T> @NotNull Future<T> submit(@NotNull @NotNull Callable<T> task)
      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.