Class SchedulerServiceQueueLimitRejector

    • Constructor Detail

      • SchedulerServiceQueueLimitRejector

        public SchedulerServiceQueueLimitRejector​(SchedulerService parentScheduler,
                                                  int queuedTaskLimit)
        Constructs a new SchedulerServiceQueueLimitRejector with the provided scheduler and limit.
        Parameters:
        parentScheduler - Scheduler to execute and schedule tasks on to
        queuedTaskLimit - Maximum number of queued tasks before executions should be rejected
      • SchedulerServiceQueueLimitRejector

        public SchedulerServiceQueueLimitRejector​(SchedulerService parentScheduler,
                                                  int queuedTaskLimit,
                                                  RejectedExecutionHandler rejectedExecutionHandler)
        Constructs a new SchedulerServiceQueueLimitRejector with the provided scheduler and limit.
        Parameters:
        parentScheduler - Scheduler to execute and schedule tasks on to
        queuedTaskLimit - Maximum number of queued tasks before executions should be rejected
        rejectedExecutionHandler - Handler to accept tasks which could not be executed due to queue size
        Since:
        4.8.0
    • Method Detail

      • getWaitingForExecutionTaskCount

        public int getWaitingForExecutionTaskCount()
        Description copied from interface: SchedulerService
        Returns how many tasks are either waiting to be executed. A value here can indicate the pool is being starved for threads.
        Specified by:
        getWaitingForExecutionTaskCount in interface SchedulerService
        Returns:
        quantity of tasks waiting execution
      • remove

        public boolean remove​(java.lang.Runnable task)
        Description copied from interface: SchedulerService
        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.

        Specified by:
        remove in interface SchedulerService
        Parameters:
        task - The original runnable provided to the executor
        Returns:
        true if the runnable was found and removed
      • remove

        public boolean remove​(java.util.concurrent.Callable<?> task)
        Description copied from interface: SchedulerService
        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.

        Specified by:
        remove in interface SchedulerService
        Parameters:
        task - The original callable provided to the executor
        Returns:
        true if the callable was found and removed
      • getActiveTaskCount

        public int getActiveTaskCount()
        Description copied from interface: SchedulerService
        Call to check how many tasks are currently being executed in this scheduler.
        Specified by:
        getActiveTaskCount in interface SchedulerService
        Returns:
        current number of running tasks
      • isShutdown

        public boolean isShutdown()
        Description copied from interface: SchedulerService
        Function to check if the thread pool is currently accepting and handling tasks.
        Specified by:
        isShutdown in interface SchedulerService
        Returns:
        true if thread pool is running