Boost logo

Boost :

From: David Maisonave (dmaisonave_at_[hidden])
Date: 2006-01-30 14:05:06

"Sam Partington" <sam.partington_at_[hidden]> wrote in message
> > You can avoid having to make the implementation thread safe by
> > making the pointee thread safe. This can be done by using an
> > intrusive lock.
> How? The FAQ is talking about making the reference count thread safe,

> not the object thread safe.
> class A { };
> void f(ptr<A> a) { }
> int main()
> {
> ptr<A> a(new A);
> boost::thread t(boost::bind(f, a));
> }
> Which thread does the deallocation of a? What protects both of them
> from trying to deallocate it at the same time?
> > I guess this could be considered not enough of an advantage if 22%
> > to 30% extra efficiency is not that important. But some developers
> > would differ.
> Until there is a thread safe implemenation then any performance
> comparisons are irrelevant because you're comparing apples and
> oranges.

Thanks for the clarification Sam, but I know what the FAQ is talking
I stand by my statement.
The smart pointer can be made thread safe by using an intrusive lock.

The idea behind this, is if you lock the pointee, before trying to
access the smart pointer's data members, than you have a thread safe
smart pointer.
With the smart pointer I'm proposing, you can have a 10 reference link
smart pointers, and if one of them has the pointee locked, than the
others will not be able to access their data members until the pointee
is unlocked.

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