java.lang.Runnable, Container, Destroyable, Dumpable, LifeCycle, ExecutionStrategy@ManagedObject("eat what you kill execution strategy") public class EatWhatYouKill extends ContainerLifeCycle implements ExecutionStrategy, java.lang.Runnable
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).
AbstractLifeCycle.AbstractLifeCycleListenerContainer.InheritedListener, Container.ListenerExecutionStrategy.ProducerLifeCycle.ListenerFAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING| Constructor | Description |
|---|---|
EatWhatYouKill(ExecutionStrategy.Producer producer,
java.util.concurrent.Executor executor) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
dispatch() |
Initiates (or resumes) the task production and consumption.
|
long |
getEPCTasksConsumed() |
|
long |
getPCTasksConsumed() |
|
long |
getPECTasksExecuted() |
|
long |
getPICTasksExecuted() |
|
boolean |
isIdle() |
|
void |
produce() |
Initiates (or resumes) the task production and consumption.
|
void |
reset() |
|
void |
run() |
|
java.lang.String |
toString() |
|
java.lang.String |
toStringLocked() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeanspublic EatWhatYouKill(ExecutionStrategy.Producer producer, java.util.concurrent.Executor executor)
public void dispatch()
ExecutionStrategyInitiates (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)dispatch in interface ExecutionStrategyExecutionStrategy.produce()public void run()
run in interface java.lang.Runnablepublic void produce()
ExecutionStrategyInitiates (or resumes) the task production and consumption.
The produced task may be run by the same thread that called this method.
produce in interface ExecutionStrategyExecutionStrategy.dispatch()@ManagedAttribute(value="number of tasks consumed with PC mode", readonly=true) public long getPCTasksConsumed()
@ManagedAttribute(value="number of tasks executed with PIC mode", readonly=true) public long getPICTasksExecuted()
@ManagedAttribute(value="number of tasks executed with PEC mode", readonly=true) public long getPECTasksExecuted()
@ManagedAttribute(value="number of tasks consumed with EPC mode", readonly=true) public long getEPCTasksConsumed()
@ManagedAttribute(value="whether this execution strategy is idle", readonly=true) public boolean isIdle()
@ManagedOperation(value="resets the task counts", impact="ACTION") public void reset()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toStringLocked()
Copyright © 1995–2018 Webtide. All rights reserved.