Boost logo

Boost Users :

From: Noel Yap (noel.yap_at_[hidden])
Date: 2006-04-18 21:36:25


On 4/18/06, me22 <me22.ca_at_[hidden]> wrote:
> As usual when you want fancy scope control, you can use a pointer.
> One of the smart pointers to the lock would work nicely.

Or how about making a smart pointer itself manage the lock? I
especially like Alexendrescu's LockingPtr, but rather than go with his
OOTB implementation, factor out the mutex into a wrapper class so you
end up with class implementors not caring about multi-threadedness and
clients explicitly choosing whether or not they want thread safety.
For example, something like:

Lockable< MyClass > myClass;
LockingPtr< MyClass > myClassPtr( myClass );

Noel


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