Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Joe Seigh Date : Sun Apr 17 2005 07:55 am On Sat, 16 Apr 2005 23:20:17 +0300, Peter Dimov wrote: > Joe Seigh wrote: >> You're need to atomically load the object and count ptrs at the same >> time so you know their associated with each other. This is a problem if >> you're trying to avoid atomic double word loads because not all platforms >> have it. Put an extra ptr to object in refcount object. > > The count object already contains an extra pointer. The problem is that, in > general, it isn't the same as the object pointer. If I have something like > I'm not sure what you mean. Never the same or sometimes not the same? If the latter, being out of sync isn't a problem. If you're reading a shared pointer around the time it's being changed, you might get the old value or you might get the new value. Which ever way, the value you get is protected by the hazard pointer. Although having the object pointer in the shared pointer like that doesn't hurt anything, I don't think saving the extra load instruction buys you that much compared to classical SMR hazard pointer overhead. To access the object, you're not dereferencing the shared pointer directly, you're dereferencing the SMR hazard pointer. -- Joe Seigh .