Boost logo

Boost Users :

Subject: [Boost-users] [shared_ptr] Is reference counting thread safe in boost 1.38
From: dhruva (dhruva_at_[hidden])
Date: 2009-02-21 01:26:19


Hello, I am trying to replace a home grown shared pointer which uses expensive lock (mutex) to make the increment and decrement thread safe. I went through the boost code and see it uses atomic operations. I am not able to figure out if the following case is handled: 1. Thread 1 has a shared_ptr and hence the reference is 1 2. Thread 1 is in the process of decrementing the reference and thread 2 is in the process of incrementing the the reference 3. If thread 1 succeeds in decrementing, the reference will become 0 and hence 'destroy' will get called. 4. Can thread 2 increment after when thread 1 is in a call to destroy? The reference count variable is itself protected but is the call to destroy and reference count variable synchronized? -dhruva Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/


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