Boost logo

Boost Users :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2004-07-14 07:38:45


I've been perusing the source code of <boost/shared_ptr.hpp> and
noticed that it uses the <boost/detail/shared_count.hpp> class to do
reference counting and not <boost/detail/atomic_count.hpp> (unless
BOOST_NO_MEMBER_TEMPLATES or BOOST_MSVC6_MEMBER_TEMPLATES are
defined).

Can anyone comment on the reasoning behind using a lightweight
mutex-protected counter instead of an atomic counter? I'd think that
an atomic counter would be faster, but I suspect that there is a good
reason for protecting the count with a mutex. This then begs the
question of why use the atomic counter in the situations mentioned
above?

Thanks.

-- 
Caleb Epstein
caleb.epstein_at_[hidden]

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