From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-09-28 07:12:48
John Torjo <john.lists_at_[hidden]> wrote:
> Ben Hutchings wrote:
> > expired() may read the count as still being 1 and so return false,
> > but I believe the wnd_shared_ptr constructor will catch the fact
> > that the pointer really has expired. Unfortunately I can't yet
> > see the code to confirm this!
> By looking at the code, I would think not. But I may be wrong.
> Anyway, I've posted the code in my other post.
Thanks for that. Supposing that expired() wrongly returns false
because use_count is really 0 but it gets an old non-zero value.
Then lock() attempts to construct a shared_ptr:
calls shared_ptr<T>::shared_ptr<T>(weak_ptr<T> const &)
calls detail::shared_count::shared_count(weak_count const &)
long volatile &)
either reads the count as 0
or calls _InterlockedCompareExchange
fails and returns 0
then loops around and reads the count as 0
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk