netty/netty — pull request #742 by trustin (2012-11-15 21:06:59+00:00)
Title: [#62][#643] ByteBufPool API

Still in progress. Changes so far:

# Remove reference counting:

I think reference counting only complicates things. The life cycle of a pooled buffer is mostly bound to the life cycle of a Channel, so user does not really need to free it by him/herself. If a user wants to use the buffer content after the Channel is deregistered, he/she can always make a copy. At worst, we can bring it back by adding Unsafe.acquire().

# Add Pooled which provides a global buffer pool:

Pooled is a pooled counterpart of Unpooled. It allows you to create a pooled buffer when you don't have a specific ByteBufPool instance you want to use. For now, it uses UnpooledByteBufPool, which does not do any pooling, but subsequent commits will use proper pool implementation.

# Other changes:

* Add AbstractNonWrappedByteBuf to reduce code duplication
* Move ChannelBuf.isPooled() to ByteBuf because we're not going to pool a MessageBuf
* Non-pooled buffers do not release anything on unsafe().release(). Only pooled buffers will release.
* SwappedByteBuf, Unsafe, and internal NIO buffer are instantiated lazily to fix performance regression.