Slightly off-topic: BlockingQueue vs CountdownLatch or other better solutions

"이희승 (Trustin Lee)" trustin at gmail.com
Thu Jun 17 07:53:07 EDT 2010


The answer is: you should not use such inter-thread communication if you
want high performance.  Instead, you can put the code that consumes the
received data inside your handler.

HTH,
Trustin

On 06/17/2010 12:24 AM, Chew Kok Hoor wrote:
> Hi all,
> 
>     I am looking at the Factorial example and see the usage of a
> BlockingQueue to hand-off the result of a Client Channel back to the
> main code that initiates the connection.
> 
>     This pattern is very similar to the pattern I require for a Systems
> Integration project my team is developing. The problem with integration
> is, most of the time you are dealing with relatively synchronous
> scenario, but I would love to standardize on Netty as the single library
> of choice for all our communications requirements. This way, we can
> benefit from choosing either to wait or not to wait for results, rather
> than having re-code again.
> 
>     The question is, what is a recommended way to hand-off the result of
> a Client Channel response back to the code that initiates the
> connection? Will CountdownLatch be more efficient compared to
> implementing a BlockingQueue, say if BlockingQueue will always be size
> of 1 anyway. Or will a simple Thread.wait with timeout and checking for
> the result from the Handler in a while loop be more efficient? I believe
> discovering the cheapest method to do this will be a key differentiator
> for many who needs to use this pattern, but would rather have a wait and
> see approach because sometimes, programming using direct Java API using
> old io can be easier and yield better performance in the short run, yet,
> if this difference is negligible, NIO will have the edge because you do
> not have to worry that the code cannot scale when needed.
> 
> Thanks.
> 
> Regards,
>     Kok Hoor
> 
> 
> 
> _______________________________________________
> 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: 293 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100617/cc6e2988/attachment.bin 


More information about the netty-users mailing list