This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch ping


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();

jon



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]