Package org.threadly.concurrent
Interface SchedulerService
-
- All Superinterfaces:
java.util.concurrent.Executor
,SubmitterExecutor
,SubmitterScheduler
- All Known Subinterfaces:
PrioritySchedulerService
,StatisticPriorityScheduler
- All Known Implementing Classes:
AbstractPriorityScheduler
,DefaultPriorityWrapper
,NoThreadScheduler
,NoThreadSchedulerStatisticTracker
,PriorityDelegatingScheduler
,PriorityScheduler
,PrioritySchedulerServiceQueueLimitRejector
,PrioritySchedulerStatisticTracker
,PrioritySchedulerTaskInterceptor
,SchedulerServiceLimiter
,SchedulerServiceQueueLimitRejector
,SchedulerServiceTaskInterceptor
,SingleThreadScheduler
,SingleThreadSchedulerStatisticTracker
,SingleThreadSchedulerSubPool
,ThreadRenamingPriorityScheduler
,ThreadRenamingSchedulerService
public interface SchedulerService extends SubmitterScheduler
This interface adds some more advanced features to a scheduler that are more service oriented. Things like a concept of running/shutdown, as well as removing tasks are not always easy to implement.- Since:
- 4.3.0 (since 2.0.0 as SchedulerServiceInterface)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getActiveTaskCount()
Call to check how many tasks are currently being executed in this scheduler.int
getQueuedTaskCount()
Returns how many tasks are either waiting to be executed, or are scheduled to be executed at a future point.int
getWaitingForExecutionTaskCount()
Returns how many tasks are either waiting to be executed.boolean
isShutdown()
Function to check if the thread pool is currently accepting and handling tasks.boolean
remove(java.lang.Runnable task)
Removes the runnable task from the execution queue.boolean
remove(java.util.concurrent.Callable<?> task)
Removes the callable task from the execution queue.-
Methods inherited from interface org.threadly.concurrent.SubmitterExecutor
submit, submit, submit
-
Methods inherited from interface org.threadly.concurrent.SubmitterScheduler
schedule, scheduleAtFixedRate, scheduleWithFixedDelay, submitScheduled, submitScheduled, submitScheduled
-
-
-
-
Method Detail
-
remove
boolean remove(java.lang.Runnable task)
Removes the runnable task from the execution queue. It is possible for the runnable to still run until this call has returned.Note that this call has high guarantees on the ability to remove the task (as in a complete guarantee). But while this is being invoked, it will reduce the throughput of execution, so should NOT be used extremely frequently.
For non-recurring tasks using a future and calling
Future.cancel(boolean)
can be a better solution.- Parameters:
task
- The original runnable provided to the executor- Returns:
true
if the runnable was found and removed
-
remove
boolean remove(java.util.concurrent.Callable<?> task)
Removes the callable task from the execution queue. It is possible for the callable to still run until this call has returned.Note that this call has high guarantees on the ability to remove the task (as in a complete guarantee). But while this is being invoked, it will reduce the throughput of execution, so should NOT be used extremely frequently.
For non-recurring tasks using a future and calling
Future.cancel(boolean)
can be a better solution.- Parameters:
task
- The original callable provided to the executor- Returns:
true
if the callable was found and removed
-
getActiveTaskCount
int getActiveTaskCount()
Call to check how many tasks are currently being executed in this scheduler.- Returns:
- current number of running tasks
-
getQueuedTaskCount
int getQueuedTaskCount()
Returns how many tasks are either waiting to be executed, or are scheduled to be executed at a future point. This can indicate pool back pressure, but it can also just indicate generally scheduled tasks. It's computationally cheaper thangetWaitingForExecutionTaskCount()
.- Returns:
- quantity of tasks waiting execution or scheduled to be executed later
-
getWaitingForExecutionTaskCount
int getWaitingForExecutionTaskCount()
Returns how many tasks are either waiting to be executed. A value here can indicate the pool is being starved for threads.- Returns:
- quantity of tasks waiting execution
-
isShutdown
boolean isShutdown()
Function to check if the thread pool is currently accepting and handling tasks.- Returns:
true
if thread pool is running
-
-