------- Comment #15 from bert dot hubert at netherlabs dot nl  2005-11-08 11:58 
-------
Subject: Re:  __gnu_cxx::__exchange_and_add is called even for single threaded
applications

On Tue, Nov 08, 2005 at 11:50:24AM -0000, pcarlini at suse dot de wrote:
> Of course does the right thing, there is no doubt about this. But, again,
> it's inconsistent and ugly adding conditionals all around only in basic_string
> and not touching all the other places. We simply want to do the same thing
> that mt_alloc is already doing, centralized in one place.

How about we make (or I contribute) a set of 'atomic-if-needed'
'exchange-and-add' and 'add' inlineable functions?

These could just replace __gnu_cxx::__exchange_and_add in all places and
automatically do the right thing: lock when needed and just add otherwise.

The added bonus is that for unthreaded applications, still the majority,
everything is inlined anyhow, which even works on i386.

My fear is that otherwise the unthreaded case is never ever going to see
real use as the amount of people that will recompile their compiler or
libstdc++ is going to be rather minimal.

Thanks.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24704

Reply via email to