Class GTaskExecutorService<ES extends ExecutorService>

java.lang.Object
com.glitchybyte.glib.concurrent.GTaskExecutorService<ES>
Type Parameters:
ES - An ExecutorService or descendant.
All Implemented Interfaces:
AutoCloseable, Executor
Direct Known Subclasses:
GTaskRunnerService, GTaskSchedulerService

public abstract sealed class GTaskExecutorService<ES extends ExecutorService> extends Object implements Executor, AutoCloseable permits GTaskRunnerService, GTaskSchedulerService
Abstract class for task runner facilities.
  • Field Details

  • Constructor Details

    • GTaskExecutorService

      public GTaskExecutorService(ES runner)
      Creates a task runner with the given ExecutorService.

      This runner owns the given ExecutorService and will shut it down and close it when the runner is closed.

      Parameters:
      runner - ExecutorService to use as runner.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • createTaskWrapper

      protected Runnable createTaskWrapper(GTask task)
      Creates a wrapper around the given GTask that sets the thread name, if given, and marks task as done when it's done.
      Parameters:
      task - GTask to wrap.
      Returns:
      A wrapped GTask in a Runnable.
    • execute

      public void execute(Runnable command)
      Specified by:
      execute in interface Executor