Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2001-08-22 07:57:48

Scott McCaskill wrote:

> Thanks for the tip. It looks like ZooLib has ref_counting_ (rather than
> _counted_) pointers, i.e. intrusive reference counting. FWIW, I've
> developed what I consider to be an optimal or near optimal intrusive
> reference counting scheme in C++, where I define 'optimal' to be 'difficult
> or preferably impossible to circumvent the reference counting mechanism but
> with minimal requirements of classes derived from the reference-counted base
> class'. For example, I would prefer that nothing outside of the smart


> pointer class be able to change the reference count of a reference-counted
> object, and I would even like for it to be impossible to ever get a raw
> pointer to a reference-counted object.

The attached emails show a problem with my "thread safe reference
count". If yours has the same problem, then the advice from
kaz_at_[hidden] (in the 2nd email) might be helpful to you.
In particular, if you ever do what I did in the main program in the
attachment, you'll have to increment the reference count from "outside
the smart pointer class" just before the pthread_create call to avoid
the problem, or, as Kaz points out, never pass the address of an auto
variable, even if its a "thread safe reference counted" SmartPtr.

Boost list run by bdawes at, gregod at, cpdaniel at, john at