Class PrioritisedThreadPool.ExecutorGroup.ThreadPoolExecutor

java.lang.Object
ca.spottedleaf.concurrentutil.executor.thread.PrioritisedThreadPool.ExecutorGroup.ThreadPoolExecutor
All Implemented Interfaces:
PrioritisedExecutor
Enclosing class:
PrioritisedThreadPool.ExecutorGroup

public final class PrioritisedThreadPool.ExecutorGroup.ThreadPoolExecutor extends Object implements PrioritisedExecutor
  • Method Details

    • halt

      public void halt()
      Removes this queue from the thread pool without shutting the queue down or waiting for queued tasks to be executed
    • isActive

      public boolean isActive()
      Returns whether this executor is scheduled to run tasks or is running tasks, otherwise it returns whether this queue is not halted and not shutdown.
    • shutdown

      public boolean shutdown()
      Description copied from interface: PrioritisedExecutor
      Prevent further additions to this executor. Attempts to add after this call has completed (potentially during) will result in IllegalStateException being thrown.

      This operation is atomic with respect to other shutdown calls

      After this call has completed, regardless of return value, this executor will be shutdown.

      Specified by:
      shutdown in interface PrioritisedExecutor
      Returns:
      true if the executor was shutdown, false if it has shut down already
      See Also:
    • isShutdown

      public boolean isShutdown()
      Description copied from interface: PrioritisedExecutor
      Returns whether this executor has shut down. Effectively, returns whether new tasks will be rejected. This method does not indicate whether all the tasks scheduled have been executed.
      Specified by:
      isShutdown in interface PrioritisedExecutor
      Returns:
      Returns whether this executor has shut down.
    • setMaxParallelism

      public void setMaxParallelism(int maxParallelism)
    • getTotalTasksScheduled

      public long getTotalTasksScheduled()
      Description copied from interface: PrioritisedExecutor
      Returns the number of tasks that have been scheduled are pending to be scheduled.
      Specified by:
      getTotalTasksScheduled in interface PrioritisedExecutor
    • getTotalTasksExecuted

      public long getTotalTasksExecuted()
      Description copied from interface: PrioritisedExecutor
      Returns the number of tasks that have been executed.
      Specified by:
      getTotalTasksExecuted in interface PrioritisedExecutor
    • generateNextSubOrder

      public long generateNextSubOrder()
      Description copied from interface: PrioritisedExecutor
      Generates the next suborder id.
      Specified by:
      generateNextSubOrder in interface PrioritisedExecutor
      Returns:
      The next suborder id.
    • executeTask

      public boolean executeTask()
      Description copied from interface: PrioritisedExecutor
      Executes the next available task.

      If there is a task with priority Priority.BLOCKING available, then that such task is executed.

      If there is a task with priority Priority.IDLE available then that task is only executed when there are no other tasks available with a higher priority.

      If there are no tasks that have priority Priority.BLOCKING or Priority.IDLE, then this function will be biased to execute tasks that have higher priorities.

      Specified by:
      executeTask in interface PrioritisedExecutor
      Returns:
      true if a task was executed, false otherwise
    • queueTask

      Description copied from interface: PrioritisedExecutor
      Queues or executes a task at Priority.NORMAL priority.
      Specified by:
      queueTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter
    • queueTask

      public PrioritisedExecutor.PrioritisedTask queueTask(Runnable task, Priority priority)
      Description copied from interface: PrioritisedExecutor
      Queues or executes a task.
      Specified by:
      queueTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      priority - The priority for the task.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter
    • queueTask

      public PrioritisedExecutor.PrioritisedTask queueTask(Runnable task, Priority priority, long subOrder)
      Description copied from interface: PrioritisedExecutor
      Queues or executes a task.
      Specified by:
      queueTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      priority - The priority for the task.
      subOrder - The task's suborder.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter
    • createTask

      Description copied from interface: PrioritisedExecutor
      Creates, but does not queue or execute, a task at Priority.NORMAL priority.
      Specified by:
      createTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter
    • createTask

      public PrioritisedExecutor.PrioritisedTask createTask(Runnable task, Priority priority)
      Description copied from interface: PrioritisedExecutor
      Creates, but does not queue or execute, a task at Priority.NORMAL priority.
      Specified by:
      createTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      priority - The priority for the task.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter
    • createTask

      public PrioritisedExecutor.PrioritisedTask createTask(Runnable task, Priority priority, long subOrder)
      Description copied from interface: PrioritisedExecutor
      Creates, but does not queue or execute, a task at Priority.NORMAL priority.
      Specified by:
      createTask in interface PrioritisedExecutor
      Parameters:
      task - The task to run.
      priority - The priority for the task.
      subOrder - The task's suborder.
      Returns:
      null if the current thread immediately executed the task, else returns the prioritised task associated with the parameter