Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2006-04-19 14:10:23


If you decide to use shared_ptr implementation from boost, then you do not need scoped_lock class
at all... All you need is a custom deleter class, which will unlock the object when the shared_ptr
is destroyed or create a copy constructible mutex lock. Take a look at the following sample, or
better study all the samples:

http://www.boost.org/libs/smart_ptr/sp_techniques.html#as_lock

With Kind Regards,

Ovanes Markarian

On Wed, April 19, 2006 3:23, me22 said:
> On 4/18/06, Paul Baxter <pauljbaxter_at_[hidden]> wrote:
>> All the examples I've seen show scoped locks being constructed local to a
>> function and then destroyed automatically at the end of function scope.
>>
>> I would like my own lock manager object to manage a group of locks and allow
>> me to leave one or more mutexes locked across function calls until the lock
>> manager object goes out of scope and releases any mutexes still flagged as
>> locked.
>>
> As usual when you want fancy scope control, you can use a pointer.
> One of the smart pointers to the lock would work nicely.
>
> IIRC you can also explicitly *un*lock scoped locks, so you might be
> able to have your manager lock them all on construction then unlock as
> nessesary.
>
> ~ SWMc
>


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