Subj : Re: Lock Free Programming with Boost::shared_ptr instead of Hazard Pointers To : comp.programming.threads From : Joe Seigh Date : Tue Mar 22 2005 09:06 am On Mon, 21 Mar 2005 14:43:14 -0800, SenderX wrote: >> BTW, they're like a herd of cats now in c.l.c++.m. They're all over >> the place. > > ;) > > > >> They have no clue what Hazard pointers are really >> appropiate for. > > Yeah. They seem to want to use hazard pointers to implement a lock-free > shared_ptr. That would be way to expensive and the scalability would be > horrible. I am finding that hazard-pointers can be fairly useful to protect > proxy collector objects... > > It's possible that someone is trying to get them to implement distributed reference counting using thread local queues for the reference count increments and decrements to be processed by a separate thread. The queues would be single reader / single writer lock-free. The polling thread periodically processes the queues. If a refcount goes to zero, it marks the object pending deletion. If the refcount is still zero after processing all currently existing refcount ops, the object is deleted. If you're going for thread-safe as int, it's fairly straight forward. If you're going for atomic thread-safe then you need to use something like Hazard Pointers to indicate any possible increments. You need to deal with queue full situations. This is a distributed algorithm so the main thing going for it is being cache friendly, hence two separate pointers, one to the object and one to the refcount with another pointer there to the object, requiring double wide cas (cas2) for atomic opts on pointers. There may be implementations out there, since this is a known technique. -- Joe Seigh .