From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-05-17 16:39:33
----- Original Message -----
From: "Eric D Crahen" <crahen_at_[hidden]>
> > Eric, your GuardedObject *IS* the same thing as the locking_ptr<> I've
> > referred you to. And your above implementation is flawed.
> It was just for demonstration; but the main difference is that locking_ptr
> (my GuardedObject) doesn't have to do anything at all with the locks - i'm
> just inheriting all that directly from the ScopedLock (my Guard). So all
> that needs to be dealt with then is just the operators and other things
> not explicitly doing and synchronization. You could probably just use an
> ownership policy as some of the others suggested to fix the flaw easily.
> The main thing is that there is only one scope that is controlling the
> lifetime, unless there is a way for a Proxy to outlive the GuardedObject
> that I'm missing.
No, there are two scopes. In Bjarne's implementation the scopes are
operator->() (for lock) and the Proxy (for unlock), while in yours they are
Proxy instance 1 (the constructed object in operator->(), for lock) and
Proxy instance 2 (the temporary returned from operator->(), for unlock).
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk