Class StealingScheduledThreadPool
java.lang.Object
ca.spottedleaf.concurrentutil.scheduler.Scheduler
ca.spottedleaf.concurrentutil.scheduler.StealingScheduledThreadPool
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longSchedules new tasks to the threads which are loaded the least.static final longSchedules new tasks to the nearest threads for the thread scheduling the task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(SchedulableTick tick) Returnsfalseif the task is not scheduled or is cancelled, returnstrueif the task was cancelled by this threadThread[]Returns all threads in the scheduler that are alive.Thread[]Returns all threads in the scheduler which are allocated for executing tasks.getNuma()voidhalt()Attempts to prevent further execution of tasks.booleanbooleanjoin(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.booleanjoinInterruptable(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.voidnotifyTasks(SchedulableTick tick) Indicates that intermediate tasks are available to be executed by the task.voidschedule(SchedulableTick tick) Schedules the specified task to be executed on this thread pool.booleansetFlags(long flags) booleansetThreadAllocation(it.unimi.dsi.fastutil.ints.Int2IntMap threadsPerNode, long stealThresholdNS, long taskTimeSliceNS)
-
Field Details
-
FLAG_SCHEDULE_EVENLY
public static final long FLAG_SCHEDULE_EVENLYSchedules new tasks to the threads which are loaded the least.- See Also:
-
FLAG_SCHEDULE_NEAR
public static final long FLAG_SCHEDULE_NEARSchedules 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
-
-
Method Details
-
getNuma
-
getAliveThreads
Description copied from class:SchedulerReturns all threads in the scheduler that are alive.- Specified by:
getAliveThreadsin classScheduler
-
getCoreThreads
Description copied from class:SchedulerReturns all threads in the scheduler which are allocated for executing tasks.- Specified by:
getCoreThreadsin classScheduler
-
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:SchedulerAttempts to prevent further execution of tasks. -
join
public boolean join(long msToWait) Description copied from class:SchedulerWaits until all threads in this pool have shutdown, or until the specified time has passed. -
joinInterruptable
Description copied from class:SchedulerWaits until all threads in this pool have shutdown, or until the specified time has passed.- Specified by:
joinInterruptablein classScheduler- Parameters:
msToWait- Maximum time to wait.- Returns:
falseif the maximum time passed,trueotherwise.- Throws:
InterruptedException- If this thread is interrupted.
-
schedule
Description copied from class:SchedulerSchedules the specified task to be executed on this thread pool. -
notifyTasks
Description copied from class:SchedulerIndicates that intermediate tasks are available to be executed by the task.- Specified by:
notifyTasksin classScheduler- Parameters:
tick- The specified task- See Also:
-
cancel
Description copied from class:SchedulerReturnsfalseif the task is not scheduled or is cancelled, returnstrueif the task was cancelled by this thread
-