Class TaskExecutor

java.lang.Object
dev.despical.pixelpainter.service.TaskExecutor
All Implemented Interfaces:
AutoCloseable

public final class TaskExecutor extends Object implements AutoCloseable
Runs bounded image and file work and returns results to the global region thread.

Two workers share a queue with eight waiting tasks. Saturation reports a configured queue-full failure instead of allocating an unbounded backlog. Worker tasks must not access live Bukkit worlds or send player messages.

Success and failure callbacks are scheduled on the global region thread while the plugin is enabled. Shutdown stops accepting work and gives pending file operations up to ten seconds to finish. A completed journal remains usable on disk even when shutdown prevents delivery of its callback.

  • Constructor Details

    • TaskExecutor

      public TaskExecutor(org.bukkit.plugin.java.JavaPlugin plugin)
      Creates the bounded executor without starting any work.
      Parameters:
      plugin - owner used to schedule callbacks
  • Method Details

    • submit

      public <T> void submit(Callable<T> task, Consumer<T> completed, Consumer<Exception> failed)
      Submits a task and delivers its result on the global region thread.
      Type Parameters:
      T - result type
      Parameters:
      task - blocking work without live world access
      completed - global-region success callback
      failed - global-region error callback; rejection is delivered immediately
    • close

      public void close()
      Stops submissions and waits for pending work before interrupting workers.
      Specified by:
      close in interface AutoCloseable