PATCH: _Atomic_swap implementation for g++-v3/bits/stl_threads.h

Loren James Rittle rittle@latour.rsch.comm.mot.com
Thu Oct 4 17:46:00 GMT 2001


In article < 20011003215803.A17312@shell7.ba.best.com > you write:

> Please forgive me if this has already been discussed, but can't
> this be done orders of magnitude more efficiently by delegating 
> to the existing libstdc++ atomic operations?  

Hi Nathan,

I too assume the answer to your final question is yes.

I knew of this option when I wrote the header comment right above the
new implementation provided by Dimitris' patch (and granted it should
have been updated when his patch went in):

// We don't provide an _Atomic_swap in this configuration.  This only
// affects the use of ext/rope with threads.  Someone could add this
// later, if required.  You can start by cloning the __STL_PTHREADS
// path while making the obvious changes.  Later it could be optimized
// to use the atomicity.h abstraction layer from libstdc++-v3.

Are the atomic operations from libstdc++ available and working on
every platform that supports gthr?  If so, I would have no problem
changing the implementation to use the atomic operation abstractions
(probably better to do so before we ever ship it in 3.1).

My understanding is that Dimitris has a multi-threaded code base that
he uses against the rope implementation.  Perhaps, we could convince
him to investigate the alternate implementation so that the first way
it ships in gcc 3.1 is closer to optimal.  OTOH, it should be noted
that this only affects getting a C string reference to a rope string.
Is that case worth the optimization (especially, if we have to add
extra configuration paths)?

Regards,
Loren



More information about the Libstdc++ mailing list