[shared_ptr] locking issues in Multithreads and singlethreaded env.

Hi As far as we know, boost::shared_ptr has a locking overhead when inc/dec is invoked. I wonder: 1. Is it using atomic op? 2. Why Alexandrescu policy based shared_ptr was rejected? 3. What can we do in order to be able to use shared_ptr without that overhead? Thanks, Kobi.

Kobi Cohen-Arazi wrote:
Hi
As far as we know, boost::shared_ptr has a locking overhead when inc/dec is invoked.
I wonder: 1. Is it using atomic op?
It depends on the platform.
3. What can we do in order to be able to use shared_ptr without that overhead?
You can #define BOOST_SP_DISABLE_THREADS. http://www.boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety
2. Why Alexandrescu policy based shared_ptr was rejected?
A policy-based smart pointer never got to the "formal review" stage. David Held was very close to submitting one and has made a formal review request: http://lists.boost.org/Archives/boost/2005/08/91848.php but I don't remember what happened. Maybe he pulled it. However the Loki version is, I believe, actively maintained. http://loki-lib.sourceforge.net/
participants (2)
-
Kobi Cohen-Arazi
-
Peter Dimov