On Wed, Apr 30, 2008 at 1:29 PM, Daniel Wirtz <[EMAIL PROTECTED]> wrote: > Another advantage is, that the coherent composite stream could be ... [snip] > Also > completely consumed byte arrays could be freed automatically by removing the > reference from the stream.
I thought it might be worth picking up on Daniel's point here. After reading a discussion a while ago about direct ByteBuffers, I've been thinking about approaches for automatically handling their allocation and deallocation. Daniel's suggestion - that a stream can handle the deallocation automatically - seems like a great solution to this problem. The good thing about a severely restricted interface like a stream is that: (a) we can prevent references to ByteBuffers from escaping (b) the consumer can only read forward, not back, so we know when a ByteBuffer is finished with. This means we do not need to rely on automatic garbage collection for disposal. We know when a ByteBuffer is garbage, so we can do it ourself. This means we can use a potentially more efficient scheme, like pooling. I'm pretty new to MINA, so this may already have been thought about, or implemented, or perhaps it's not even a problem! Anyway, I thought I'd mention it, since it seemed like a possible benefit of a stream interface. (And this does not in any way detract from the current Iteratable<BufferBuffer>/ByteBuffer proposals floating around either - streams may not be appropriate or necessary for all IoFilters.) Cheers Rich -- Rich Dougherty http://blog.richdougherty.com/
