Interface ManagedRunnable

All Superinterfaces:
Runnable
All Known Subinterfaces:
ObjectRunnable<O1,O2>
All Known Implementing Classes:
AbstractObjectRunnable, AbstractObjectSpecificExecutor.FlushTask, ObjectOneWorkRunnable, PipelineRunnable, ScheduledObjectOneWorkRunnable

public interface ManagedRunnable extends Runnable
A runnable of which the executor manages the submitted executions. AbstractObjectSpecificExecutor signals when an execution of this runnable has been submitted, that is, handed to a pool, and when the pool has rejected this execution instead of running it – even when the rejection does not throw, e. g. a handler for rejected executions which swallows the task. Implementations account for the executions between submission and start this way, e. g. for awaiting the termination of an object runnable or for counting the flush tasks admitted to the pool, and an execution which will never take place does not corrupt this accounting.

A handler for rejected executions of such an executor either throws, swallows the task or executes it within the calling thread. A handler which hands the task to a different thread is not supported: the task runs after the rejection has been processed, so the accounting cannot tell its execution from the execution of another submission.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Signals that submitting an execution of this runnable has failed, that is, the pool has rejected it.
    void
    Signals that an execution of this runnable has been submitted, that is, handed to a pool for execution.

    Methods inherited from interface java.lang.Runnable

    run
  • Method Details

    • submitted

      void submitted()
      Signals that an execution of this runnable has been submitted, that is, handed to a pool for execution. The execution counts for the termination from now on, that is, for the time between being handed to the pool and being started (or rejected) by it. Awaiting the termination therefore awaits the execution although it has not started yet: work which has been submitted before a flush completes before the task of the flush and no work runs concurrently to this task.
    • rejected

      void rejected()
      Signals that submitting an execution of this runnable has failed, that is, the pool has rejected it. This reverts submitted() since the execution will not take place.
      Nothing is reverted if the execution has started meanwhile, e. g. a handler for rejected executions which executes the task within the calling thread: Runnable.run() counts such an execution itself, so reverting would count it twice.