ChannelBuffer to byte array
"Trustin Lee (이희승)"
trustin at gmail.com
Wed Mar 3 04:50:15 EST 2010
Hi Shay,
I think it is safe even if you do not copy the content of the array if
the happens-before condition meets. For example, this is safe:
Thread A:
sharedByteArray[0] = 1;
taskQueue.offer(something);
Thread B:
taskQueue.poll(); // get something
assert sharedByteArray[0] == 1;
For more information, read this article:
http://www.ibm.com/developerworks/library/j-jtp03304/
HTH,
Trustin
Shay Banon wrote:
> Just to clarify this (and correct me if I am wrong here Trustin), if
> then, you are going to use that byte array in another thread (for
> example, using the execution handler), then you have to copy it over.
> For example, in your http request message handler which then delegates
> the handling of the Http request to another thread.
>
> -shay.banon
>
> On Wed, Mar 3, 2010 at 7:56 AM, "Trustin Lee (이희승)"
> <trustin at gmail.com <mailto:trustin at gmail.com>> wrote:
>
> Adam,
>
> Netty 3.2 adds array() and hasArray() to ChannelBuffer.
>
> In 3.1, you can call toByteBuffer() which will not involve memory copy
> if possible.
>
> HTH,
> Trustin
>
> Adam Durana wrote:
> > Hi,
> >
> > I'm looking for the most efficient way to get a ChannelBuffer's data
> > in the form of a byte array. The byte array will be only read from
> > and not modified. Is the best way to use a ChannelBuffer's readBytes
> > method to copy the data into an array? Or is there a way that doesn't
> > involve copying given that I'm not going to be modifying the array?
> >
> > Thanks,
> > Adam
> > _______________________________________________
> > netty-users mailing list
> > netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
> > https://lists.jboss.org/mailman/listinfo/netty-users
>
> --
> what we call human nature in actuality is human habit
> http://gleamynode.net/
>
>
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100303/75277610/attachment.bin
More information about the netty-users
mailing list