Subject: Re: [boost] atomic_count::operator++ return type
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-04-12 09:24:06
JOAQUIN M. LOPEZ MUÑOZ:
> This does not work because of scenarios like the following:
> 1. Thread A detaches the last reference to x and is preempted
> when it's about to enter erase.
> 2. Thread B retrieves x so that its refcount is now 1. After
> some work with x, thread B detaches the reference to x,
> whose refcount drops again to zero, enters erase and
> eliminates x.
> 3. Thread A resumes, but erase now attempts to work with
> a nonexistent x.
Here by x you mean the refcounted_value, I guess. Yes, this doesn't work if
'Handle' is a raw pointer, for example. I think, however, that it does work
if erase doesn't need to dereference the handle in order to see that it's
already been removed.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk