Boost logo

Boost Users :

From: Colin Fox (cfox_at_[hidden])
Date: 2002-02-16 12:43:26


On Sat, 2002-02-16 at 03:37, Peter Dimov wrote:
<..>
> OK, let me explain the exact level of thread safety provided by shared_ptr;
> it might be of help.
>
> shared_ptr (in 1.27+) is (should be) thread neutral. A class X is thread
> neutral when:
>
> * Accessing two different objects of class X is safe, even when they are
> equivalent copies;
> * Accessing the same object is safe only when all accesses are read
> accesses; otherwise the behavior is undefined.
<..>
> If your program doesn't read/write or write/write (to) the same shared_ptr
> simultaneously, and still misbehaves, then there is a bug in shared_ptr that
> we'll have to track down.

The problem I'm having is simply that one thread destroys it's smart
pointer to an object, and the object gets destroyed while another thread
is still using that object.

Once these shared objects are created, all threads only read them, so
it's not that kind of read/write conflict. I just need the object to
hang around until no more threads need it.

I got the CVS version of boost, which you suggested, and had my program
running all night last night. No problems so far. Perhaps this solves
it.
 

-- 
Colin Fox
CF Consulting Inc.
cfox_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net