Boost logo

Boost Users :

Subject: [Boost-users] [Thread] Read-write locks
From: lfrfly_at_[hidden]
Date: 2011-01-27 17:37:38


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.


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