Boost logo

Boost Users :

From: Austin Bingham (austin.bingham_at_[hidden])
Date: 2005-07-05 14:36:43

Is there any notion of recursive locking for the read-write mutex?
Specifically, if a thread has a write-lock on a mutex, is there any
way to have recursive read- or write-locks on that mutex pass
immediately? Notionally, it seems that permission to write to
something presumes permission to read it. However, when I try to
read-lock a mutex which is already write-locked (in the same thread),
I get deadlock.

I would be happy to use the promote-demote functionality of the
read_write_lock, but the following excerpt from the documentation
scares me:

"[The promote() function] throws boost::lock_error if . . . the lock
cannot be promoted because another lock on the same mutex is already
waiting to be promoted."

This makes it sound like there is no way to guarantee that you can
promote a lock, even with unbounded blocking. Is this the case? Thanks
for any help on this.

Austin Bingham
"If I were creating the world I wouldn't mess about 
with butterflies and daffodils. I would have started 
with lasers, eight o'clock, Day One!" 

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at