
26 Apr
2004
26 Apr
'04
1:34 a.m.
From: "Howard Hinnant"
On Apr 25, 2004, at 7:00 AM, John Maddock wrote:
Maybe, but lets not forget that shared_ptr doesn't need a mutex at all, what it needs is an atomic counter (actually less than that, because we never need the value of the counter just whether it's less than/greater than, or equal to zero).
shared_ptr has two counts which sometimes must both be incremented in an atomic fashion.
Right, but thanks to Alexander Terekhov, this is already a solved problem. :-) I'll try to switch boost::shared_ptr to use atomic operations (on Windows at least) for the next release. Perhaps you missed the comp.std.c++ thread and my proof of concept implementation, available at http://www.pdimov.com/cpp/shared_count_x86_exp2.hpp