|
Boost : |
From: Don G (dongryphon_at_[hidden])
Date: 2005-01-04 01:46:15
Hi Roland,
>>I may be worried over something inconsequential, but the condition
>>class creates three kernel objects per instance.
>>
> There is quite a lot of archived discussion available about this
> topic. There is agreement, that on windows this is the only
reliable
> way of doing it. Beneath the boost list you might also google for
> "condition win32".
> As far as I understood the main issue that it is not possible to
> implement a condition on win32 with a single event is that it is
not
> possible to awake a single thread _and_ awake all threads.
> You can't achive both available semantics with an event alone.
I agree that if _all_ capabilities of a posix condition variable are
required, my approach would not work. I used one event per waiting
thread, the condition variable was permanently associated with the
mutex (not just when waiting), and the caller to notify/notifyAll had
to have the same mutex. Adding a lightweight_mutex to the condition
variable would enable the missing features, but as I said, I saw no
need. Sadly, I must confess that I don't understand your reference to
the Monitor pattern (been too long since I read that book) and how it
relates.
> As opposed to conditions your construct also would create a
> condition with "state". This is not a condition anymore.
It has nearly all the benefits of a full condition variable, is more
convenient (safer?) in cases where the mutex passed to wait() is
always the same, and is implementable on both platforms with minimal
overhead.
Unless I am missing something quite fundamental (which is certainly
possible<g>), the extra power of on-the-fly association and
notify-w/o-holding-mutex don't justify the cost these features
entail. I just wrote this off as a satisfactory,
least-common-denominator to gain most of the benefit condvars offer.
Thanks & Best regards!
Don
PS: I searched on "condition win32" on www.boost.org and got only 9
hits. A full google turned up an article by Douglas Schmidt that I
had read some years back (the top hit). How should I search to find
these old discussions?
=====
__________________________________
Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
http://celebrity.mail.yahoo.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk