
8 Mar
2004
8 Mar
'04
10:19 a.m.
On Fri, 5 Mar 2004 11:43:12 -0800, "John McGinty" <john@VisiCode.com> wrote:
Is there any reason why shared_ptr does not use atomic_count (using InterlockedIncrement, InterlockedDecrement) for the reference count? The lightweight mutex used to protect the count in the current implementation is a spin lock that sleeps when contended. Using atomic count would offer performance improvements in both the uncontended and contended cases.
You can't atomically modify two variables at once without some kind of mutex but there are two reference counts. I suspect that's the reason. Tom -- C++ FAQ: http://www.parashift.com/c++-faq-lite/ C FAQ: http://www.eskimo.com/~scs/C-faq/top.html