This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Patch ping
Jonathan Wakely wrote:
>Peter Dimov wrote:
>
>>Can't this be solved using atomic_compare_exchange (I'm not sure of its
>>exact spelling, or whether it's currently part of libstdc++)?
>>
>>
>I was just thinking the same thing. Currently the work you described
>is split across two functions, but would this work, given a pointer to
>the new object, "new" ...
>
> old = caches[i];
> new->add_reference();
> while ( !compare_and_swap(caches[i], old, new) )
> {
> old = caches[i];
> }
> if (old)
> old->remove_reference();
>
>
Guys, thanks a lot for the nice ideas, but remember that we have first
to figure out something for the short/mid term: for one, we don't have
the compare_and_swap primitive implemented for all the targets and, for
some, it will *never* be (i386, etc). Nothing new...
I believe in this *specific* case we can at least use mutexes without
penalizing performances.
Paolo.