In the boost::shared_ptr
destructor, this is done:
if(--*pn == 0)
{
boost::checked_delete(px);
delete pn;
}
where pn
is a pointer to the reference counter, which is typedefed as
shared_ptr::count_type -> detail::atomic_count -> long
I would have expected the long
to be volatile long
, given threaded usage and the non-atomic 0-check-and-deletion in the shared_ptr
destructor above. Why isn't it volatile?
EDIT:
It turns out I looked at the header used when multi-threaded usage is not specified (atomic_count.hpp). In atomic_count_win32.hpp, the decrement is properly implemented for multithreaded usage.