Remove volatile where not needed.

Motivation:

We can remove the volatile keyword from the cached Runnables as at worse these will just be re-created.

Modifications:

Remove volatile.

Result:

Less overhead.
This commit is contained in:
Norman Maurer 2016-05-25 16:20:07 +02:00
parent 528b83e277
commit dcd93e3be0

View File

@ -66,12 +66,11 @@ abstract class AbstractChannelHandlerContext extends DefaultAttributeMap
private int handlerState = INIT; private int handlerState = INIT;
// Lazily instantiated tasks used to trigger events to a handler with different executor. // Lazily instantiated tasks used to trigger events to a handler with different executor.
// These needs to be volatile as otherwise an other Thread may see an half initialized instance. // There is no need to make this volatile as at worse it will just create a few more instances then needed.
// See the JMM for more details private Runnable invokeChannelReadCompleteTask;
private volatile Runnable invokeChannelReadCompleteTask; private Runnable invokeReadTask;
private volatile Runnable invokeReadTask; private Runnable invokeChannelWritableStateChangedTask;
private volatile Runnable invokeChannelWritableStateChangedTask; private Runnable invokeFlushTask;
private volatile Runnable invokeFlushTask;
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor, String name, AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, EventExecutor executor, String name,
boolean inbound, boolean outbound) { boolean inbound, boolean outbound) {