netty/netty — pull request #2734 by trustin (2014-08-05 01:21:49+00:00)
Title: Refactoring in preparation to unify I/O logic for all branches

Motivation:

While trying to merge our ChannelOutboundBuffer changes we've made last week, I realized that we have quite a bit of conflicting changes at 4.1 and master. It was primarily because we added ChannelOutboundBuffer.beforeAdd() and moved some logic there, such as direct buffer conversion.

However, this is not possible with the changes we've made for 4.0. We made ChannelOutboundBuffer final for example.

Maintaining multiple branch is already getting painful and having different core will make it even worse, so I think we should keep the differences between 4.0 and other branches minimal (maybe master is fine until we merge the FJP patch.)

So, I modified the 4.0 API and added all the necessary extension points such as filterOutboundMessage() (and plus some minor cleanup as usual.)

- Move ChannelOutboundBuffer.safeRelease() to ReferenceCountUtil
- Backport ThreadLocalPooledDirectByteBuf
- TODO: Move and polish it - netty-buffers?
- Make most public methods in AbstractUnsafe final
- Add AbstractChannel.filterOutboundMessage() so that a transport can convert a message to another (e.g. heap -> off-heap), and also reject unsupported messages
- Move all direct buffer conversions to filterOutboundMessage()
- Move all message type checks to filterOutboundMessage()
- Move AbstractChannel.checkEOF() to OioByteStreamChannel, because it's the only place it is used at all

Strictly speaking, it's not a fully backward compatible change, but ChannelOutboundBuffer was never extensible practically and the added methods are either static or they are transport-implementor only with the default implementation, so I think it doesn't really matter.

Once this is merged to 4.0, I'll continue merging 4.0 to 4.1 and master.