|
Boost Users : |
Subject: Re: [Boost-users] [Thread] Read-write locks
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-09-18 01:57:11
Le 27/01/11 23:56, Howard Hinnant a écrit :
> On Jan 27, 2011, at 5:37 PM, lfrfly_at_[hidden] wrote:
>
>> I'm trying to create a standard read/write lock using Boost Threads, and I'm having a bit of difficulty mapping the Boost concepts onto the usual ones.
>>
>> A read/write lock should have several states: Locked for reading (multiple threads may lock at once), locked for writing (only one thread may lock, and no threads may be locked for reading at the same time), and unlocked. Ideally it would be nice if an RWL which is locked for reading may temporarily upgrade to locked for writing, then return to the locked for reading state.
>>
>> Boost supports several relevant notions of locking: shared locking, upgrade locking, and exclusive locking. This to me is a confusing distinction. In particular, a shared_mutex seems appropriate as the basis for a RWL, but is lock_upgrade() the equivalent of a write lock and lock_shared the equivalent of a read lock? This is unclear. If "upgrade locking" is not the same as "exclusive locking", then is an upgrade lock actually exclusive? Could someone please clarify this.
> Here is a description of the original design (with source code) of shared and upgrade locking which the boost versions are based on:
>
> http://home.roadrunner.com/~hinnant/mutexes/locking.html
This link point at https://home.roadrunner.com/rr/Home_Page_Options.html
> This design is slightly different from the boost implementations and imho superior (rationale given in the linked page). It also has many examples. If this document doesn't clear up the concepts and use cases you need, please let me know.
>
>
Howard please, beside the implementation, have you identified some
interface differences between your and the Boost.Thread classes?
Thanks in advance,
Vicente
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