netty5/transport/src/test/java/io/netty
Sergio Bossa 60a240316a Improved DefaultChannelPipeline#destroy() to avoid spinning continuously in case of custom executors.
Motivation:

The previous DefaultChannelPipeline#destroy() implementation, introduced in #3156, is suboptimal as it can cause the for loop to continuously spin if the executor used by a given handler is unable to "recognize" the event loop.
It could be objected that it's the custom executor responsibility to properly implement the inEventLoop() method, but some implementetaions might not be able to do that for performance reasons, and even so, it's always better to be safe against API misuse, in particular when it is not possible to fail fast and the alternative is rather some sutle behaviour.

Modifications:

The patch simply avoids the recursive spin by explicitly passing the "in event loop" condition as a boolean parameter, preserving the same guarantees offered by #3156. A unit test has also been added.

Result:

All channel events are correctly called and no high CPU usage is seen anymore.
2015-11-06 19:37:41 +01:00
..
bootstrap ServerBootstrap.handler(...) will add handler before Channel is registered. 2015-07-07 08:44:02 +02:00
channel Improved DefaultChannelPipeline#destroy() to avoid spinning continuously in case of custom executors. 2015-11-06 19:37:41 +01:00