Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-07-26 06:27:55

David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>>>> I prefer to be able to name the lock variable 'lock' instead of
>>>> 'lk'.
>>> Suit yourself, but I think variable names should denote roles, not
>>> types.
>> Hm. What is it that makes 'lock' not qualify as a role?
> Well, OK, it's a role at a very low level of abstraction. Something
> more like "access_foo" for some mutex-protected resource "foo" might
> be better.


    lock lk( m ); // the original examples


    scoped_lock lock( m );

Or the role-based variation:

    lock access_foo( foo_mutex );


    scoped_lock foo_lock( foo_mutex );

Same but unnamed (because you won't be touching the lock afterwards):

    lock access( foo_mutex );


    scoped_lock lock( foo_mutex );

Boost list run by bdawes at, gregod at, cpdaniel at, john at