Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #971

Re: Why is java consumer/producer so much faster than C++

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Luca Risolia <luca.risolia@studio.unibo.it>
Newsgroups comp.lang.c++, comp.programming.threads
Subject Re: Why is java consumer/producer so much faster than C++
Date Tue, 24 Jul 2012 00:33:10 +0200
Organization Aioe.org NNTP Server
Lines 17
Message-ID <jukjf6$d5a$2@speranza.aioe.org> (permalink)
References <juht3o$a3a$1@news.albasani.net> <ba6e5833-f9a2-428e-815b-aad0ebdf3c55@s6g2000pbi.googlegroups.com> <jui2a3$a3a$2@news.albasani.net> <jui4cg$d5a$1@speranza.aioe.org> <juj8ca$ges$1@news.albasani.net>
NNTP-Posting-Host Z2aAaWHo3goDty2MP7NWgA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.c++:17211 comp.programming.threads:971

Cross-posted to 2 groups.

Show key headers only | View raw


On 23/07/2012 12:17, Melzzzzz wrote:
>> (On a side note, the C++ version you have given does not have the
>> best possible interface for a thread-safe queue)
>
> I have just copied Java BlockingQueue interface, which is of course
> suited for Java. Don't know actually how ideal interface would look
> like.

In C++11 the ideal interface for a generic thread-safe and 
exception-safe queue should at least provide std::shared_ptr<T> take() 
and/or void take(T&). T take() is limited to those types having no-throw 
copy constructors or move-constructors. This also means that you should 
check the type at compile-time by using type traits. However, in your 
test case you used move-semantic everywhere, so that is not problem. 
Also note that the term "pop" instead of "take" is more in the spirit of 
C++.

Back to comp.programming.threads | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-22 23:59 +0200
  Re: Why is java consumer/producer so much faster than C++ Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-22 15:42 -0700
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 01:28 +0200
      Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-23 02:03 +0200
        Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 12:17 +0200
          Re: Why is java consumer/producer so much faster than C++ Luca Risolia <luca.risolia@studio.unibo.it> - 2012-07-24 00:33 +0200
  Re: Why is java consumer/producer so much faster than C++ Juha Nieminen <nospam@thanks.invalid> - 2012-07-23 06:37 +0000
    Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 12:33 +0200
      Re: Why is java consumer/producer so much faster than C++ Juha Nieminen <nospam@thanks.invalid> - 2012-07-23 11:46 +0000
        Re: Why is java consumer/producer so much faster than C++ Melzzzzz <mel@zzzzz.com> - 2012-07-23 15:33 +0200
  Re: Why is java consumer/producer so much faster than C++ Dombo <dombo@disposable.invalid> - 2012-07-23 22:57 +0200
    Re: Why is java consumer/producer so much faster than C++ Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-23 21:54 -0700
      Re: Why is java consumer/producer so much faster than C++ Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-24 12:50 +0000
  Re: Why is java consumer/producer so much faster than C++ Ricardo Nabinger Sanchez <rnsanchez@wait4.org> - 2012-08-14 22:48 +0000

csiph-web