4dc Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Chris Thomasson Date : Sun Apr 10 2005 06:30 am > Can I get the best of both worlds by providing the following two methods > in > shared_ptr: > > template class shared_ptr > { > // ... > > shared_ptr copy() const; > void replace( shared_ptr const & pt ); > }; > > with the guarantee that competing accesses to 'copy' and 'replace' work > (but > other competing accesses are still disallowed in order to avoid an acquire > except in 'copy')? You can. How are you going to allow for "competing access"? Are you using mutexs, or going for a lock-free method such as SMR? I am currently experimenting with using SMR to protect the reference counts of a quick lock-free atomic pointer API I did in C. Surprisingly, it seems to be more light-weight than atomic_ptr "on x86" despite the fact that it relies on the expensive SMR API in order to provide "strong" thread-safety. DWCAS can be expensive on x86. I have not compared it against Joes PPC reference counting algorithm that uses LL/SC directly, its very efficient. -- http://appcore.home.comcast.net/ (portable lock-free data-structures) . 0