Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util.thread.strategy

public Class ExecuteProduceConsume

extends Object
implements ExecutionStrategy, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, org.eclipse.jetty.util.thread.ExecutionStrategy
Imports
java.util.concurrent.Executor, org.eclipse.jetty.util.thread.AutoLock, .ExecutionStrategy, .Invocable, .Invocable.InvocationType, org.slf4j.Logger, .LoggerFactory

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private boolean
private final Executor
private boolean
private final AutoLock
private boolean
private final ExecutionStrategy.Producer
private boolean
private final Runnable
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
dispatch()

Implements org.eclipse.jetty.util.thread.ExecutionStrategy.dispatch.

Initiates (or resumes) the task production and consumption.

public Boolean
public void
produce()

Implements org.eclipse.jetty.util.thread.ExecutionStrategy.produce.

Initiates (or resumes) the task production and consumption.

private void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_executeback to summary
private boolean _execute
_executorback to summary
private final Executor _executor
_idleback to summary
private boolean _idle
_lockback to summary
private final AutoLock _lock
_pendingback to summary
private boolean _pending
_producerback to summary
private final ExecutionStrategy.Producer _producer
_producingback to summary
private boolean _producing
_runProduceback to summary
private final Runnable _runProduce
LOGback to summary
private static final Logger LOG

Constructor Detail

ExecuteProduceConsumeback to summary
public ExecuteProduceConsume(ExecutionStrategy.Producer producer, Executor executor)

Method Detail

dispatchback to summary
public void dispatch()

Implements org.eclipse.jetty.util.thread.ExecutionStrategy.dispatch.

Doc from org.eclipse.jetty.util.thread.ExecutionStrategy.dispatch.

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)
Annotations
@Override
isIdleback to summary
public Boolean isIdle()
produceback to summary
public void produce()

Implements org.eclipse.jetty.util.thread.ExecutionStrategy.produce.

Doc from org.eclipse.jetty.util.thread.ExecutionStrategy.produce.

Initiates (or resumes) the task production and consumption.

The produced task may be run by the same thread that called this method.

Annotations
@Override
produceConsumeback to summary
private void produceConsume()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.util.thread.strategy back to summary

private Class ExecuteProduceConsume.RunProduce

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.RunProduce
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RunProduceback to summary
private RunProduce()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override