Class ThreadRenamingSchedulerService
- java.lang.Object
-
- org.threadly.concurrent.AbstractSubmitterExecutor
-
- org.threadly.concurrent.AbstractSubmitterScheduler
-
- org.threadly.concurrent.wrapper.traceability.ThreadRenamingSubmitterScheduler
-
- org.threadly.concurrent.wrapper.traceability.ThreadRenamingSchedulerService
-
- All Implemented Interfaces:
java.util.concurrent.Executor,SchedulerService,SubmitterExecutor,SubmitterScheduler
public class ThreadRenamingSchedulerService extends ThreadRenamingSubmitterScheduler implements SchedulerService
Class which wraps aSchedulerServiceand wraps all supplied tasks in aThreadRenamingRunnable. This allows you to make a pool where all tasks submitted inside it have the threads named in an identifiable way.- Since:
- 4.8.0 (since 4.3.0 at org.threadly.concurrent.ThreadRenamingSchedulerServiceWrapper)
-
-
Constructor Summary
Constructors Constructor Description ThreadRenamingSchedulerService(SchedulerService scheduler, java.lang.String threadName, boolean replace)Constructs a newThreadRenamingSchedulerService, wrapping a suppliedSchedulerService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetActiveTaskCount()Call to check how many tasks are currently being executed in this scheduler.intgetQueuedTaskCount()Returns how many tasks are either waiting to be executed, or are scheduled to be executed at a future point.intgetWaitingForExecutionTaskCount()Returns how many tasks are either waiting to be executed.booleanisShutdown()Function to check if the thread pool is currently accepting and handling tasks.booleanremove(java.lang.Runnable task)Removes the runnable task from the execution queue.booleanremove(java.util.concurrent.Callable<?> task)Removes the callable task from the execution queue.-
Methods inherited from class org.threadly.concurrent.wrapper.traceability.ThreadRenamingSubmitterScheduler
scheduleAtFixedRate, scheduleWithFixedDelay
-
Methods inherited from class org.threadly.concurrent.AbstractSubmitterScheduler
schedule, submitScheduled, submitScheduled
-
Methods inherited from class org.threadly.concurrent.AbstractSubmitterExecutor
execute, submit, submit
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
-
-
-
Constructor Detail
-
ThreadRenamingSchedulerService
public ThreadRenamingSchedulerService(SchedulerService scheduler, java.lang.String threadName, boolean replace)
Constructs a newThreadRenamingSchedulerService, wrapping a suppliedSchedulerService. If /replaceisfalsethe thread will be named such thatthreadName[originalThreadName].- Parameters:
scheduler- SchedulerService to wrap and send executions tothreadName- Thread name prefix, or replaced namereplace- Iftruethe original name wont be included in the thread name
-
-
Method Detail
-
remove
public boolean remove(java.lang.Runnable task)
Description copied from interface:SchedulerServiceRemoves 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.- Specified by:
removein interfaceSchedulerService- Parameters:
task- The original runnable provided to the executor- Returns:
trueif the runnable was found and removed
-
remove
public boolean remove(java.util.concurrent.Callable<?> task)
Description copied from interface:SchedulerServiceRemoves 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.- Specified by:
removein interfaceSchedulerService- Parameters:
task- The original callable provided to the executor- Returns:
trueif the callable was found and removed
-
getActiveTaskCount
public int getActiveTaskCount()
Description copied from interface:SchedulerServiceCall to check how many tasks are currently being executed in this scheduler.- Specified by:
getActiveTaskCountin interfaceSchedulerService- Returns:
- current number of running tasks
-
getQueuedTaskCount
public int getQueuedTaskCount()
Description copied from interface:SchedulerServiceReturns 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 thanSchedulerService.getWaitingForExecutionTaskCount().- Specified by:
getQueuedTaskCountin interfaceSchedulerService- Returns:
- quantity of tasks waiting execution or scheduled to be executed later
-
getWaitingForExecutionTaskCount
public int getWaitingForExecutionTaskCount()
Description copied from interface:SchedulerServiceReturns how many tasks are either waiting to be executed. A value here can indicate the pool is being starved for threads.- Specified by:
getWaitingForExecutionTaskCountin interfaceSchedulerService- Returns:
- quantity of tasks waiting execution
-
isShutdown
public boolean isShutdown()
Description copied from interface:SchedulerServiceFunction to check if the thread pool is currently accepting and handling tasks.- Specified by:
isShutdownin interfaceSchedulerService- Returns:
trueif thread pool is running
-
-