Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] why isn't it possible to acquire 2 different upgrade_lock from 2 different threads?
From: Elad Moshe (eladm26_at_[hidden])
Date: 2014-03-27 12:09:22


> If both threads tried to upgrade, you would have a deadlock.

But how is it possible? isn't the upgrade operation atomic?
if the 2 threads try to upgrade, one will succeed and the other one will
block until the first thread will unlock.

On Thu, Mar 27, 2014 at 5:39 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> AMDG
>
> On 03/27/2014 01:21 AM, Elad Moshe wrote:
> > Hi,
> > this is my first post here so please bare with me :) .
> > I recently used upgrade_lock to try access a shared resource from 2
> > different threads.
> > I noticed that once the first thread acquired its upgrade_lock the second
> > thread was blacked
> > until the first thread unlock it.
> > can someone please explain me the logic behind this behavior?
> > isn't an upgrade lock just a shared_lock that can be upgraded to
> > unique_lock?
> > why not let both threads acquire it just like shared_lock until, and if,
> > they decide to upgrade it to unique_lock?
> >
>
> If both threads tried to upgrade, you would have a deadlock.
>
> In Christ,
> Steven Watanabe
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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