Hi Rich,

Rich Dougherty wrote:
> 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.

So far, the idea sounds very cool.  I started to be convinced. :)

Probably the remaining questions are..

1) How do we create a sliced?
2) How do we slice an InputStream if we only know the size of the slice
after we read something and the slice should begin from the first byte
of the stream?

One possible solution to Q2 is to support mark() and reset() operation
in InputStream, but it means we can't release the related resources even
if the stream has reached to its end, because reset() can be called at
any time.  We might need something better?

> 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.)

I'd love to hear from someone new to MINA.  Fresh blood comes with fresh
ideas!

Cheers,
-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to