Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-07-22 14:01:47


On Jul 22, 2004, at 1:16 PM, Eric Niebler wrote:

> Please no. The scoped_lock keeps track of whether it has locked the
> mutext or not, so it kows whether or not to unlock the mutex in its
> destructor. If you make the mutex interface public AND expose the
> mutex of the lock, you break encapsulation:
>
> mutext m;
>
> {
> scoped_lock l( m ); // locked
> l.mutext()->unlock(); // unlocked
> } // unlocked again by l's destructor!

I just knew I was getting too much in the mood of: Here's the rope,
don't hang yourself! :-)

> It is for precisely this reason that I think you shouldn't be able to
> get a pointer to the mutex from the scoped_lock. You should get back a
> token or a void* that is useful only for comparison purposes.

I'll let you and Peter hammer that one out. I could be happy with
whatever you guys decide.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk