directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daune...@daune-consult.com
Subject Re: Using Mina ByteBuffers
Date Thu, 21 Apr 2005 13:08:15 GMT
Selon Trustin Lee <trustin@gmail.com>:

> Hi,
>
> 2005/4/21, daune.jf@daune-consult.com <daune.jf@daune-consult.com>:
> > Hi,
> >
> > I wonder what I have to do to use Mina ByteBuffer implementation in my
> > application (in ProtocolDecoder, in order to copy incoming bytes until a
> > complete message is received)
>
> You could just use CumulativeProtocolDecoder that does what you want.
>
> > I especially wonder if I must acquire the buffer after calling
> > ByteBuffer.allocate (and then release it when work is done), or if
> > acquire/release is not needed.
> >
> > There is some javadoc about it:
> >
> > "Please note that you never need to release the allocated buffer because
> MINA
> > will release it automatically.
> > But, if you didn't pass it to MINA or called {@link #acquire()} by
> yourself, you
> > will have to release it manually"
> >
> > But I don't understand what is meant by "pass to MINA".
>
> I updated documentation of Acquire/Release section.  Please svn up and
> then you'll see more clear explanation.  I'll copy and paste it here:
>
> Please note that you never need to release the allocated buffer
> because MINA will release it automatically when:
>
>  * You pass the buffer by calling {@link IoSession#write(ByteBuffer,
> Object)}.</li>
>  * You pass the buffer by calling {@link
> ProtocolEncoderOutput#write(ByteBuffer)}.
>
> And, you don't need to release any {@link ByteBuffer} which is passed
> as a parameter of {@link IoHandler#dataRead(IoSession, ByteBuffer)}
> method.  They are released automatically when the method returns.
>
> You have to release buffers manually by calling {@link #release()} when:
>
>  * You allocated a buffer, but didn't pass the buffer to any of two
> methods above.</li>
>  * You called {@link #acquire()} to prevent the buffer from being
> released.</li>
>
> Is the documentation clearer now?
>
> Thanks,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
>


Perfect. This greatly clarifies ByteBuffer use.

And sorry for CumulativeProtocolDecoder. I underestimated MINA ;> !!!

Cheers,

J-F

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


Mime
View raw message