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 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 Details

    • SignallingRejectionHandler

      protected SignallingRejectionHandler(RejectedExecutionHandler delegate)
      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