|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-08-09 12:26:37
On Aug 9, 2004, at 10:26 AM, Alexander Terekhov wrote:
> Yes, but this scheme has a drawback. "Serial wakes across context
> switching" (in addition to locking across context switching). For
> alternative, see (for example)
>
> http://groups.google.com/groups?selm=3D9196B2.9BC29299%40web.de
> (Subject: Re: rwlock using pthread_cond)
The alternative in this link looks very familiar. I'm currently using
two condition variables, an unsigned, and two bools (oh, and of course
the mutex). Although after looking at your example I think I could
probably merge my unsigned and two bools into an int and one bool
(because of padding, may not be worth the effort though). My two
condition variables are used slightly differently than yours because of
the additional requirements of:
start_upgradable()
end_upgradable()
(
and of course there's the conversion-functions:
http://home.twcny.rr.com/hinnant/cpp_extensions/
threads.html#unlock_and_lock_sharable
)
Sorry I can't just show the code.
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk