<div dir="ltr">Agreed, this is why Java serialization works with final fields :). I meant something else, which I now understand that I was wrong. For some unknown reason to me, I thought that the HTTP request message, for example, does not have its own copy of ChannelBuffer.<div>
<br></div><div>-shay.banon<br><br><div class="gmail_quote">On Wed, Mar 3, 2010 at 11:50 AM, "Trustin Lee (ÀÌÈñ½Â)" <span dir="ltr"><<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Shay,<br>
<br>
I think it is safe even if you do not copy the content of the array if<br>
the happens-before condition meets. For example, this is safe:<br>
<br>
Thread A:<br>
<br>
sharedByteArray[0] = 1;<br>
taskQueue.offer(something);<br>
<br>
Thread B:<br>
<br>
taskQueue.poll(); // get something<br>
assert sharedByteArray[0] == 1;<br>
<br>
For more information, read this article:<br>
<br>
<a href="http://www.ibm.com/developerworks/library/j-jtp03304/" target="_blank">http://www.ibm.com/developerworks/library/j-jtp03304/</a><br>
<br>
HTH,<br>
Trustin<br>
<div class="im"><br>
Shay Banon wrote:<br>
> Just to clarify this (and correct me if I am wrong here Trustin), if<br>
> then, you are going to use that byte array in another thread (for<br>
> example, using the execution handler), then you have to copy it over.<br>
> For example, in your http request message handler which then delegates<br>
> the handling of the Http request to another thread.<br>
><br>
> -shay.banon<br>
><br>
> On Wed, Mar 3, 2010 at 7:56 AM, "Trustin Lee (ÀÌÈñ½Â)"<br>
</div><div class="im">> <<a href="mailto:trustin@gmail.com">trustin@gmail.com</a> <mailto:<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>>> wrote:<br>
><br>
> Adam,<br>
><br>
> Netty 3.2 adds array() and hasArray() to ChannelBuffer.<br>
><br>
> In 3.1, you can call toByteBuffer() which will not involve memory copy<br>
> if possible.<br>
><br>
> HTH,<br>
> Trustin<br>
><br>
> Adam Durana wrote:<br>
> > Hi,<br>
> ><br>
> > I'm looking for the most efficient way to get a ChannelBuffer's data<br>
> > in the form of a byte array. The byte array will be only read from<br>
> > and not modified. Is the best way to use a ChannelBuffer's readBytes<br>
> > method to copy the data into an array? Or is there a way that doesn't<br>
> > involve copying given that I'm not going to be modifying the array?<br>
> ><br>
> > Thanks,<br>
> > Adam<br>
> > _______________________________________________<br>
> > netty-users mailing list<br>
</div>> > <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a> <mailto:<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>><br>
<div class="im">> > <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
> --<br>
> what we call human nature in actuality is human habit<br>
> <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> netty-users mailing list<br>
</div>> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a> <mailto:<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>><br>
<div class="im">> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
><br>
><br>
</div>> ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">><br>
> _______________________________________________<br>
> netty-users mailing list<br>
> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
--<br>
what we call human nature in actuality is human habit<br>
<a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
<br>
<br>
</div></div><br>_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></blockquote></div><br></div></div>