Class EDFSchedulerThreadPool
java.lang.Object
ca.spottedleaf.concurrentutil.scheduler.Scheduler
ca.spottedleaf.concurrentutil.scheduler.EDFSchedulerThreadPool
Scheduler thread pool implementation that uses EDF scheduling.
Intermediate task execution is not supported in this scheduler.
NUMA aware scheduling is not supported in this scheduler.
-
Constructor Summary
ConstructorsConstructorDescriptionEDFSchedulerThreadPool(int threads, ThreadFactory threadFactory) Creates, but does not start, a scheduler thread pool with the specified number of threads created using the specified thread factory. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(SchedulableTick task) 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.Thread[]Returns an array of the underlying scheduling threads.voidhalt()Attempts to prevent further execution of tasks.booleanjoin(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 task) Indicates that intermediate tasks are available to be executed by the task.voidschedule(SchedulableTick task) Schedules the specified task to be executed on this thread pool.voidstart()Starts the threads in this pool.booleanupdateTickStartToMax(ca.spottedleaf.concurrentutil.scheduler.EDFSchedulerThreadPool.ScheduledState task, long newStart) Updates the tasks scheduled start to the maximum of its current scheduled start and the specified new start.
-
Constructor Details
-
EDFSchedulerThreadPool
Creates, but does not start, a scheduler thread pool with the specified number of threads created using the specified thread factory.- Parameters:
threads- Specified number of threadsthreadFactory- Specified thread factory- See Also:
-
-
Method Details
-
start
public void start()Starts the threads in this pool. -
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.
-
getThreads
Returns an array of the underlying scheduling threads. -
getCoreThreads
Description copied from class:SchedulerReturns all threads in the scheduler which are allocated for executing tasks.- Specified by:
getCoreThreadsin classScheduler
-
getAliveThreads
Description copied from class:SchedulerReturns all threads in the scheduler that are alive.- Specified by:
getAliveThreadsin classScheduler
-
schedule
Description copied from class:SchedulerSchedules the specified task to be executed on this thread pool. -
updateTickStartToMax
public boolean updateTickStartToMax(ca.spottedleaf.concurrentutil.scheduler.EDFSchedulerThreadPool.ScheduledState task, long newStart) Updates the tasks scheduled start to the maximum of its current scheduled start and the specified new start. If the task is not scheduled, returnsfalse. Otherwise, returns whether the scheduled start was updated. Undefined behavior of the specified task is scheduled in another executor.- Parameters:
task- Specified tasknewStart- Specified new start
-
cancel
Description copied from class:SchedulerReturnsfalseif the task is not scheduled or is cancelled, returnstrueif the task was cancelled by this thread -
notifyTasks
Description copied from class:SchedulerIndicates that intermediate tasks are available to be executed by the task.- Specified by:
notifyTasksin classScheduler- Parameters:
task- The specified task- See Also:
-