Boost logo

Boost :

From: Michael Marcin (mike_at_[hidden])
Date: 2006-10-08 05:46:15


Anthony Williams wrote:
>
> <snip >
>
> "Cory Nelson" <phrosty_at_[hidden]> writes:
>>
>> <snip>
>>
>> 3) I don't like the lock(), unlock() etc member functions being
>> public.. forcing scoped_lock is a great cheap idiom for exception
>> safety and saving people from deadlocks. Even with scoped_lock also
>> available - it isn't something found in other languages so I fear new
>> developers will flock to using the simpler and more familiar public
>> members instead.
>
> Howard's proposal has them as public members, so that's what I implemented.
>
> I can see the arguments both ways. Making the functions private is
> easy, and what boost does already.
>
> There are certainly use cases where pure scoped locks get in the way.
>

Hi,

The idea is to make it somewhat difficult to use the functions directly
but allow them when absolutely needed, yes?

You could make them protected in which case they could be accessed if
necessary simply with derivation + using. i.e.

class manual_read_write_mutex : public read_write_mutex
{
public:
     using read_write_mutex::lock;
     using read_write_mutex::unlock;
};

or is this too ugly?

- Mike


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