Boost logo

Boost :

From: Wyss, Felix (felixw_at_[hidden])
Date: 2002-02-11 10:50:12

> And, of course, for the lock to have a meaning, all shared_ptr reference
> count operations must also lock.
> I don't see a way to avoid the (relatively expensive) lock.

But without the ability to obtain a strong reference from a weak, the weak_ptr is useless in MT applications. I would even consider it dangerous to put it into boost in the current incarnation, as inexperienced programmers may use it and get very hard to find bugs.

There are many situations where the strong/weak reference pattern is very useful, in particular in MT applications. As the reference tracking is more expensive than the straight shared_ptr, why not provide a separate set of strong_ptr/weak_ptr templates?

I implemented strong/weak reference ptr templates that we're using internally. It uses a spin-lock similar to the one implemented by the STLport sub-allocation manager and the locking overhead is very small (at least on Win32, but I presume the same applies to any platform that has an efficient atomic exchange operation).


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