Class Scheduler
java.lang.Object
ca.spottedleaf.concurrentutil.scheduler.Scheduler
- Direct Known Subclasses:
EDFSchedulerThreadPool,StealingScheduledThreadPool
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancancel(SchedulableTick tick) Returnsfalseif the task is not scheduled or is cancelled, returnstrueif the task was cancelled by this threadabstract 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 voidhalt()Attempts to prevent further execution of tasks.abstract booleanjoin(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.abstract booleanjoinInterruptable(long msToWait) Waits until all threads in this pool have shutdown, or until the specified time has passed.abstract voidnotifyTasks(SchedulableTick tick) Indicates that intermediate tasks are available to be executed by the task.abstract voidschedule(SchedulableTick tick) Schedules the specified task to be executed on this thread pool.
-
Constructor Details
-
Scheduler
public Scheduler()
-
-
Method Details
-
getAliveThreads
Returns all threads in the scheduler that are alive. -
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:
falseif the maximum time passed,trueotherwise.
-
joinInterruptable
Waits until all threads in this pool have shutdown, or until the specified time has passed.- Parameters:
msToWait- Maximum time to wait.- Returns:
falseif the maximum time passed,trueotherwise.- Throws:
InterruptedException- If this thread is interrupted.
-
schedule
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
Indicates that intermediate tasks are available to be executed by the task.- Parameters:
tick- The specified task- See Also:
-
cancel
Returnsfalseif the task is not scheduled or is cancelled, returnstrueif the task was cancelled by this thread
-