Class CountingRejectedExecutionHandler
- java.lang.Object
-
- org.opendaylight.yangtools.util.concurrent.CountingRejectedExecutionHandler
-
- All Implemented Interfaces:
RejectedExecutionHandler
public class CountingRejectedExecutionHandler extends Object implements RejectedExecutionHandler
A RejectedExecutionHandler that delegates to a backing RejectedExecutionHandler and counts the number of rejected tasks.- Author:
- Thomas Pantelis
-
-
Constructor Summary
Constructors Constructor Description CountingRejectedExecutionHandler(RejectedExecutionHandler delegate)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getRejectedTaskCount()
Returns the rejected task count.static CountingRejectedExecutionHandler
newAbortPolicy()
Returns a counting handler for rejected tasks that throws a RejectedExecutionException.static CountingRejectedExecutionHandler
newCallerRunsPolicy()
Returns a counting handler for rejected tasks that runs the rejected task directly in the calling thread of the execute method, unless the executor has been shut down, in which case the task is discarded.static CountingRejectedExecutionHandler
newCallerWaitsPolicy()
Returns a counting handler for rejected tasks that blocks on theThreadPoolExecutor
's backing queue until it can add the task to the queue.void
rejectedExecution(Runnable task, ThreadPoolExecutor executor)
-
-
-
Constructor Detail
-
CountingRejectedExecutionHandler
public CountingRejectedExecutionHandler(RejectedExecutionHandler delegate)
Constructor.- Parameters:
delegate
- the backing RejectedExecutionHandler.
-
-
Method Detail
-
rejectedExecution
public void rejectedExecution(Runnable task, ThreadPoolExecutor executor)
- Specified by:
rejectedExecution
in interfaceRejectedExecutionHandler
-
getRejectedTaskCount
public long getRejectedTaskCount()
Returns the rejected task count.
-
newCallerRunsPolicy
public static CountingRejectedExecutionHandler newCallerRunsPolicy()
Returns a counting handler for rejected tasks that runs the rejected task directly in the calling thread of the execute method, unless the executor has been shut down, in which case the task is discarded.
-
newAbortPolicy
public static CountingRejectedExecutionHandler newAbortPolicy()
Returns a counting handler for rejected tasks that throws a RejectedExecutionException.
-
newCallerWaitsPolicy
public static CountingRejectedExecutionHandler newCallerWaitsPolicy()
Returns a counting handler for rejected tasks that blocks on theThreadPoolExecutor
's backing queue until it can add the task to the queue.
-
-