Boost logo

Boost Users :

From: Dizzy (dizzy_at_[hidden])
Date: 2007-04-17 03:57:12


Hello

struct A {}

// executes before spawning any boost threads
shared_ptr<A> sp(new A());
weak_ptr<A> wp(sp);

// then in thread1
sp.reset();

// in thread thread2
shared_ptr<A> sp2(wp.lock());

Is the above code thread safe ? Is sp2 always either a default initilized
shared_ptr<A> or a valid shared_ptr to the instance of A initially referenced
by sp ?

I couldn't find documentation on weak_ptr thread safety issues just on
shared_ptr. I am unable to determine from the documentation what is the
intended behaivour for the above code. I could look into the boost code
and/or test it but I want to know not how it works but how it's intended to
work (portably and all) :)

Thank you.

-- 
Mihai RUSU					Email: dizzy_at_[hidden]
GPG : http://dizzy.roedu.net/dizzy-gpg.txt	WWW: http://dizzy.roedu.net
			"Linux is obsolete" -- AST

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