
Mattias Brändström wrote:
Sebastian Redl wrote: [snip]
class LockProxy { public: LockProxy(boost::shared_ptr<T> p, boost::shared_ptrboost::recursive_mutex mutex) : p_(p), lock_(*mutex) { }
const boost::shared_ptr<T> &operator->() { return p_; }
private: boost::shared_ptr<T> p_; boost::recursive_mutex::scoped_lock lock_; };
I've also changed the return type of operator ->. There's no need to create a copy of the shared_ptr.
I'll use these changes in my implementation.
Actually, it seems that I will not be able to have the lock as member of LockProxy since it's boost::noncopyable. LockPointer's operator->() returns a LockProxy by value and needs to copy all member of it to do so. I can't see any way around this so I need to have a pointer to the lock in LockProxy. Perhaps someone else can see a way to not have to use a pointer to the lock? :.:: mattias