Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Joe Seigh Date : Sat Apr 16 2005 10:12 am On Sat, 16 Apr 2005 15:52:09 +0300, Peter Dimov wrote: > For me, the most painful part of a hazard pointer implementation is the > pointer-per-thread table (ac_thread.c). (There are some issues with > destruction and deallocation but they probably can be solved.) Making the table dynamically resizable would be a little tricky but doable. I don't think you'd need more than one or two hazard pointers though. Big problem is getting rid of the hazard pointer memory barrier but that's doable also. > > But there's one other thing: shared_ptr is two pointers, not one. Without > DWCAS, or at least double-wide atomic loads and stores, even hazards aren't > enough to make it atomic. :-( > Sounds like it's using separate refcount and object pointers to make dereferencing the object less expensive, as opposed to keeping the object pointer with the refcount which is what I do with atomic_ptr. It's an implementation issue. If you want atomicity you do whatever it takes. You need a compiler that's smarter about optimization maybe. -- Joe Seigh .