Boost logo

Boost :

From: Chris Elliott (cpelliott_at_[hidden])
Date: 2002-05-06 10:30:53


I guess I missunderstood the orignal question. It is
true that

sp1 = sp2;

is unsafe if sp2 can change during the operation, so
passing around a pointer to a smart_ptr (or a pointer
to a struct with a smart_ptr, etc.) between threads is
unsafe. A smart_ptr global would be another way you
could run into thread trouble.

You can however dynamically allocate a struct
containing a smart_ptr, copy your smart_ptr to it
(this assumes no other task has visibility to the
source smart_ptr), and send it to another task for
use.

--- Larry Evans wrote:
> Couldn't the source be in another thread; hence,
> could go out-of-scope?
...
> The rule is:
>
> You can't access a smart_ptr across threads.
> You can only access the
> pointee across threads because the pointee is
> guarded by the mutex.

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk