Class StealingScheduledThreadPool

java.lang.Object
ca.spottedleaf.concurrentutil.scheduler.Scheduler
ca.spottedleaf.concurrentutil.scheduler.StealingScheduledThreadPool

public final class StealingScheduledThreadPool extends Scheduler
  • Field Details

    • FLAG_SCHEDULE_EVENLY

      public static final long FLAG_SCHEDULE_EVENLY
      Schedules new tasks to the threads which are loaded the least.
      See Also:
    • FLAG_SCHEDULE_NEAR

      public static final long FLAG_SCHEDULE_NEAR
      Schedules new tasks to the nearest threads for the thread scheduling the task.
      See Also:
    • DEFAULT_FLAGS

      public static final long DEFAULT_FLAGS
      See Also:
  • Constructor Details

    • StealingScheduledThreadPool

      public StealingScheduledThreadPool(ThreadFactory threadFactory, OSNuma numa)
  • Method Details

    • getNuma

      public OSNuma getNuma()
    • getAliveThreads

      public Thread[] getAliveThreads()
      Description copied from class: Scheduler
      Returns all threads in the scheduler that are alive.
      Specified by:
      getAliveThreads in class Scheduler
    • getCoreThreads

      public Thread[] getCoreThreads()
      Description copied from class: Scheduler
      Returns all threads in the scheduler which are allocated for executing tasks.
      Specified by:
      getCoreThreads in class Scheduler
    • isShutdown

      public boolean isShutdown()
    • setThreadAllocation

      public boolean setThreadAllocation(it.unimi.dsi.fastutil.ints.Int2IntMap threadsPerNode, long stealThresholdNS, long taskTimeSliceNS)
    • setFlags

      public boolean setFlags(long flags)
    • halt

      public void halt()
      Description copied from class: Scheduler
      Attempts to prevent further execution of tasks.
      Specified by:
      halt in class Scheduler
    • join

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

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

      public void schedule(SchedulableTick tick)
      Description copied from class: Scheduler
      Schedules the specified task to be executed on this thread pool.
      Specified by:
      schedule in class Scheduler
      Parameters:
      tick - Specified task
      See Also:
    • notifyTasks

      public void notifyTasks(SchedulableTick tick)
      Description copied from class: Scheduler
      Indicates that intermediate tasks are available to be executed by the task.
      Specified by:
      notifyTasks in class Scheduler
      Parameters:
      tick - The specified task
      See Also:
    • cancel

      public boolean cancel(SchedulableTick tick)
      Description copied from class: Scheduler
      Returns false if the task is not scheduled or is cancelled, returns true if the task was cancelled by this thread
      Specified by:
      cancel in class Scheduler