Class Scheduler

java.lang.Object
ca.spottedleaf.concurrentutil.scheduler.Scheduler
Direct Known Subclasses:
EDFSchedulerThreadPool, StealingScheduledThreadPool

public abstract class Scheduler extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    Returns false if the task is not scheduled or is cancelled, returns true if the task was cancelled by this thread
    abstract Thread[]
    Returns all threads in the scheduler that are alive.
    abstract Thread[]
    Returns all threads in the scheduler which are allocated for executing tasks.
    abstract void
    Attempts to prevent further execution of tasks.
    abstract boolean
    join(long msToWait)
    Waits until all threads in this pool have shutdown, or until the specified time has passed.
    abstract boolean
    joinInterruptable(long msToWait)
    Waits until all threads in this pool have shutdown, or until the specified time has passed.
    abstract void
    Indicates that intermediate tasks are available to be executed by the task.
    abstract void
    Schedules the specified task to be executed on this thread pool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Scheduler

      public Scheduler()
  • Method Details

    • getAliveThreads

      public abstract Thread[] getAliveThreads()
      Returns all threads in the scheduler that are alive.
    • getCoreThreads

      public abstract Thread[] getCoreThreads()
      Returns all threads in the scheduler which are allocated for executing tasks.
    • halt

      public abstract void halt()
      Attempts to prevent further execution of tasks.
    • join

      public abstract boolean join(long msToWait)
      Waits until all threads in this pool have shutdown, or until the specified time has passed.
      Parameters:
      msToWait - Maximum time to wait.
      Returns:
      false if the maximum time passed, true otherwise.
    • joinInterruptable

      public abstract boolean joinInterruptable(long msToWait) throws InterruptedException
      Waits until all threads in this pool have shutdown, or until the specified time has passed.
      Parameters:
      msToWait - Maximum time to wait.
      Returns:
      false if the maximum time passed, true otherwise.
      Throws:
      InterruptedException - If this thread is interrupted.
    • schedule

      public abstract void schedule(SchedulableTick tick)
      Schedules the specified task to be executed on this thread pool.
      Parameters:
      tick - Specified task
      Throws:
      IllegalStateException - If the task is already scheduled, or if the task start is not set
      See Also:
    • notifyTasks

      public abstract void notifyTasks(SchedulableTick tick)
      Indicates that intermediate tasks are available to be executed by the task.
      Parameters:
      tick - The specified task
      See Also:
    • cancel

      public abstract boolean cancel(SchedulableTick tick)
      Returns false if the task is not scheduled or is cancelled, returns true if the task was cancelled by this thread