Class EatWhatYouKill

  • All Implemented Interfaces:
    java.lang.Runnable, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, ExecutionStrategy

    @ManagedObject("eat what you kill execution strategy")
    public class EatWhatYouKill
    extends ContainerLifeCycle
    implements ExecutionStrategy, java.lang.Runnable
    The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.

    A strategy where the thread that produces will run the resulting task if it is possible to do so without thread starvation.

    This strategy preemptively dispatches a thread as a pending producer, so that when a thread produces a task it can immediately run the task and let the pending producer thread take over production. When operating in this way, the sub-strategy is called Execute Produce Consume (EPC).

    However, if the task produced uses the Invocable API to indicate that it will not block, then the strategy will run it directly, regardless of the presence of a pending producer thread and then resume production after the task has completed. When operating in this pattern, the sub-strategy is called ProduceConsume (PC).

    If there is no pending producer thread available and if the task has not indicated it is non-blocking, then this strategy will dispatch the execution of the task and immediately continue production. When operating in this pattern, the sub-strategy is called ProduceExecuteConsume (PEC).

    The EatWhatYouKill strategy is named after a hunting proverb, in the sense that one should kill(produce) only to eat(consume).

    • Constructor Detail

      • EatWhatYouKill

        public EatWhatYouKill​(ExecutionStrategy.Producer producer,
                              java.util.concurrent.Executor executor)
    • Method Detail

      • dispatch

        public void dispatch()
        Description copied from interface: ExecutionStrategy

        Initiates (or resumes) the task production and consumption.

        This method guarantees that the task is never run by the thread that called this method.

        TODO review the need for this (only used by HTTP2 push)
        Specified by:
        dispatch in interface ExecutionStrategy
        See Also:
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • getPICTasksExecuted

        @ManagedAttribute(value="number of tasks executed with PIC mode",
        public long getPICTasksExecuted()
      • getPECTasksExecuted

        @ManagedAttribute(value="number of tasks executed with PEC mode",
        public long getPECTasksExecuted()
      • getEPCTasksConsumed

        @ManagedAttribute(value="number of tasks consumed with EPC mode",
        public long getEPCTasksConsumed()
      • toStringLocked

        public java.lang.String toStringLocked()