
Hi, What does "undefined" mean in the shared_ptr documentation about thread safety? http://www.boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety I'd like to be able to do simultaneous read/writes, but on a global shared pointer without locking, but I'm unsure of the consequences. -John

Basically, I want to know if the following code is guaranteed to not crash: boost::shared_ptr<int> shared_int; // thread 1 while (true) { if (rand() < MAX_RAND / 2) { shared_int = boost::shared_ptr<int>(new int(rand())); } else { shared_int.reset(); } } // thread 2 while (true) { boost::shared_ptr<int> my_int = shared_int; if (my_int.get()) { printf("%d\n", *my_int); } } On 6/16/06, John Ky <newhoggy@gmail.com> wrote:
Hi,
What does "undefined" mean in the shared_ptr documentation about thread safety?
http://www.boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety
I'd like to be able to do simultaneous read/writes, but on a global shared pointer without locking, but I'm unsure of the consequences.
-John
participants (1)
-
John Ky