Class AbstractObjectSpecificExecutor.SignallingRejectionHandler
java.lang.Object
de.aristaflow.adept2.util.threading.executor.AbstractObjectSpecificExecutor.SignallingRejectionHandler
- All Implemented Interfaces:
RejectedExecutionHandler
- Enclosing class:
- AbstractObjectSpecificExecutor<O1,
O2, R>
protected static final class AbstractObjectSpecificExecutor.SignallingRejectionHandler
extends Object
implements RejectedExecutionHandler
A handler for rejected executions which signals the rejection to the affected
object runnable and delegates to the actual handler
otherwise. A handler which swallows the rejected task, e. g. a
The delegate is called first: a delegate which throws, e. g. an
DiscardPolicy, would leave the runnable with an execution which never takes place,
so awaiting its termination would never return.The delegate is called first: a delegate which throws, e. g. an
AbortPolicy, is handled by
AbstractObjectSpecificExecutor.executeUnchecked(Runnable) itself, and a delegate which
executes the task within the calling thread has executed it once it returns. Such an execution
of an object runnable is detected by comparing the executions the calling thread has started
before and after the delegate, so no rejection is signalled for the executed task. The count of
the submitted executions cannot detect it: an execution which has been submitted in the
meantime replenishes it, so signalling the rejection could revert this other execution instead
of the executed task. A delegate which hands the task to a different thread is not supported,
see ManagedRunnable.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new handler for rejected executions signalling the rejection to the affected object runnable. -
Method Summary
Modifier and TypeMethodDescriptionprotected RejectedExecutionHandlerGets the actual handler for rejected executions to which this handler delegates.voidrejectedExecution(Runnable command, ThreadPoolExecutor executor)
-
Constructor Details
-
SignallingRejectionHandler
Creates a new handler for rejected executions signalling the rejection to the affected object runnable.- Parameters:
delegate- The actual handler for rejected executions to which to delegate.
-
-
Method Details
-
getDelegate
Gets the actual handler for rejected executions to which this handler delegates.- Returns:
- The actual handler for rejected executions to which this handler delegates.
-
rejectedExecution
- Specified by:
rejectedExecutionin interfaceRejectedExecutionHandler
-