A strategy where the thread that produces will always run the resulting task.
The strategy may then dispatch another thread to continue production.
The strategy is also known by the nickname 'eat what you kill', which comes from the hunting ethic that says a person should not kill anything he or she does not plan on eating. In this case, the phrase is used to mean that a thread should not produce a task that it does not intend to run. By making producers run the task that they have just produced avoids execution delays and avoids parallel slow down by running the task in the same core, with good chances of having a hot CPU cache. It also avoids the creation of a queue of produced tasks that the system does not yet have capacity to consume, which can save memory and exert back pressure on producers.
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final Executor | |
| private boolean | |
| private final AutoLock | |
| private boolean | |
| private final ExecutionStrategy. | |
| private boolean | |
| private final Runnable | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | dispatch()
Implements org. Initiates (or resumes) the task production and consumption. |
| public Boolean | |
| public void | produce()
Implements org. Initiates (or resumes) the task production and consumption. |
| private void | |
| public void | |
| public String |
| _execute | back to summary |
|---|---|
| private boolean _execute | |
| _executor | back to summary |
|---|---|
| private final Executor _executor | |
| _idle | back to summary |
|---|---|
| private boolean _idle | |
| _lock | back to summary |
|---|---|
| private final AutoLock _lock | |
| _pending | back to summary |
|---|---|
| private boolean _pending | |
| _producer | back to summary |
|---|---|
| private final ExecutionStrategy. | |
| _producing | back to summary |
|---|---|
| private boolean _producing | |
| _runProduce | back to summary |
|---|---|
| private final Runnable _runProduce | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| ExecuteProduceConsume | back to summary |
|---|---|
| public ExecuteProduceConsume(ExecutionStrategy. | |
| dispatch | back to summary |
|---|---|
| public void dispatch() Implements org. Doc from org. 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)
| |
| isIdle | back to summary |
|---|---|
| public Boolean isIdle() | |
| produce | back to summary |
|---|---|
| public void produce() Implements org. Doc from org. Initiates (or resumes) the task production and consumption. The produced task may be run by the same thread that called this method.
| |
| produceConsume | back to summary |
|---|---|
| private void produceConsume() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| RunProduce | back to summary |
|---|---|
| private RunProduce() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |