Boost logo

Boost :

From: Jonathan Biggar (jon_at_[hidden])
Date: 2003-07-21 18:52:13


Peter Dimov wrote:
> Russell Hind wrote:
>
>>Fair enough. My most common use is for automatically
>>locking/unlocking
>>
>>void function(void)
>>{
>>scoped_lock lock(themutex);
>> ... do something
>> lock.unlock();
>> ... do some more
>> lock.lock();
>> ... do something else
>>}
>>
>>with possible a while-loop around the unlock/lock code. From this, I
>>have seen it as a coding error if I call lock without an unlock but
>>this probably isn't the same for everyone.
>
>
> This looks like a motivating example for scoped_unlock. :-)

Yes, I've long wanted that. Particularly when the second "do some more"
involves a "long" operation that you don't want to hold the lock while
it is pending.

-- 
Jon Biggar
Floorboard Software
jon_at_[hidden]
jon_at_[hidden]

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