Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 1999-12-28 20:23:48

boris fomitchev <fb-_at_[hidden]> wrote:
original article:
> I do believe good strategy is to add default bool template argument :
> template < class T, bool Synchronized = false>
> class shared_ptr
> .....
> shared_ptr then should or should not use atomic operations depending
> on Synchronized value. On most platforms, difference would not be
> noticeable, though (using assembly), so it might even make sense to
> default to Synchronized=true or even use it always.

A thread parameter to me seems like a feature creep that goes too far.
As pointed out earlier in this thread, often the atomic operation
dealing with the smart pointer occurs within a larger section of code
that needs to be atomic anyway. The question is how often is this the
case. My threading experience is light, but I've tended to find that
I'll do several operations on a object that all need to be protected
together. I don't want the boost smart pointers to encourage using too
small a granularity for critical sections.

> SGI STL provide examples on how it can be done.

The examples of the SGI STL show a container is simply not thread-safe
(in the sense that a write to the container is not atomic). The
documentation talks about how the user can create their own wrapper
(e.g. locked_queue) if atomic operations are desired.

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