[ http://issues.apache.org/jira/browse/DIRMINA-165?page=all ]
Federico Bonelli updated DIRMINA-165:
-------------------------------------
Attachment: ByteBuffer.java
In the MINA byteBuffer.asReadOnly() I create a new mina DefaultByteBuffer
container and get into that the nio.buffer copy and the reference to the
original mina bytebuffer, and a boolean flag that says if the DefaultByteBuffer
wrap a readOnly copy or a real writable nio.bytebuffer. I do an aquire() of the
original MINA byteBuffer.
(Errata Corrige: instead of the flag I have used the reference to the original
buffer: if it is null I think that it is not a copy)
So when the MINA ByteBuffer copy is released, the release method just look at
the flag and release the original mina bytebuffer.
The MINA bytebuffer copy _must_ be not pooled obviusly.
In this way there is no need to make a copy of the data, but only a new
nio.bytebuffer that use the same byte[] or direct array, and the original
ByteBuffer will be released only when all the copies will be already written to
the channel.
This implementation do not work well with the expand features.
All the stuff I have added are marked with a "DIRMINA 165" comment.
> Easy and performant copy of the ByteBuffer
> ------------------------------------------
>
> Key: DIRMINA-165
> URL: http://issues.apache.org/jira/browse/DIRMINA-165
> Project: Directory MINA
> Type: Improvement
> Versions: 0.8, 0.9, 0.8.1, 0.8.2
> Reporter: Federico Bonelli
> Priority: Minor
> Attachments: ByteBuffer.java
>
> Until now if you wish to broadcast a message you must create by your own the
> bytebuffer copies, it would be better to provide a ByteBuffer.asReadOnly()
> method that create a copy that share the data with the original ByteBuffer
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira