Boost logo

Boost :

Subject: Re: [boost] [thread] unlock on multiple lockables
From: Alan Manuel Gloria (almkglor_at_[hidden])
Date: 2009-11-22 23:25:34


On Mon, Nov 23, 2009 at 10:08 AM, Vicente Botet Escriba
<vicente.botet_at_[hidden]> wrote:
>
> Hi,
>
> I don't know if I have already requested that but ...
>
> Is there any deep reason to don't provide the equivalent of the free
> functions lock, try_lock
>
> Non-member function lock(Lockable1,Lockable2,...)
> Non-member function lock(begin,end)
> Non-member function try_lock(Lockable1,Lockable2,...)
> Non-member function try_lock(begin,end)
>
> to unlock multiple lockables?
>
> Non-member function unlock(Lockable1,Lockable2,...)
> Non-member function unlock(begin,end)

Probably because locking order can cause deadlocks if the order is
different for each locker, but unlocking does not. I assume that the
multi-arg locking functions are a way to ensure that there is a
globally-defined lock ordering (usually implemented by sorting
according to address of mutex). Since unlocking does not have
deadlock problems due to unlocking order, it was probably deemed
unnecessary to have multi-arg unlocking.

Of course, now that you mention it, a multi-unlock would probably be
somewhat convenient in a few cases.

Sincerely,
AmkG


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