Boost logo

Boost Users :

From: Mattias Brandstrom (thebrasse_at_[hidden])
Date: 2006-09-11 05:39:35


Mattias Brändström wrote:
> Sebastian Redl wrote:
[snip]
>>>class LockProxy {
>>>public:
>>>LockProxy(boost::shared_ptr<T> p,
>>>boost::shared_ptr<boost::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


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