Windows event objects still considered harmful?

Hi, I don't agree with the rationale for excluding a Windows event object-like construct from the Boost thread package. The rationale justifies the exclusion based on the "Concurrent Programming Concepts" paper by Per Brich Hansen in which event variables are dismissed as unsafe. The fundamental problem of event variables according to Hansen's paper is that, "if the sender causes [signals] the event before the receiver waits for it, the receiver will remain delayed until the next event is caused [signalled]". However, Windows event objects don't work like this. From the API specification: "When the state of an auto-reset event object is signaled, it remains signaled until a single waiting thread is released; the system then automatically resets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled." In other words, the receiver will _not_ remain delayed if the sender signals the event before the receiver waits for it. Based on this observation, I think the reference to Hansen's paper should be removed from the rationale. It does not apply to Windows event objects and I had to spend $10 to download the paper from the ACM website and find this out. Furthermore, according to the rationale, "Experienced programmers using the Windows platform today report that event variables are a continuing source of errors". Are there any links to documents that describe these problems? Are these problems perhaps related to the PulseEvent() method, which does cause the behaviour Hansen described but has been deprecated (the API documentation states "This function is unreliable and should not be used. It exists mainly for backward compatibility"). In short, are Windows event objects still considered harmful? Thanks, Robin Boerdijk __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

"Robin Boerdijk" <robin_boerdijk@yahoo.com> wrote in message news:20060112151043.59600.qmail@web33201.mail.mud.yahoo.com...
That discussion was four or five years ago so my memory may be faulty, but isn't the real problem that if no threads are available (because events are happening faster than they can be disposed of) then events will be silently dropped? IIRC, Brich Hansen argued that threading primatives should work correctly regardless of the relative speed of each tread, and that was why the docs referenced him.
Some of the war stories appeared in list discussions, so you might check the archives. Seems to me the topic also came up over a beer with some Microsoft VC++ folks in Redmond in 2001 after Bill Kempf presented Boost.Threads to the C++ committee, and they had also seen the problems.
To rehabilitate them you would need to show not only that they aren't harmful, but that they are somehow better that the alternatives, that they have POSIX threads equivalents, that threading experts endorse them, etc., etc. Threading is such a minefield that many people are very reluctant to accept features just because programmers claim to have used them successfully. Programmers claimed goto's were fine, too, but they eventually fell into disfavor. --Beman

It's not that I want events to be rehabilitated in Boost but I object to the _rationale_ for not including them in Boost. The rationale says they are evil but the basis for that is unclear to me. They are all over the place in Windows. Even CRITICAL_SECTION uses them internally. In another post, I wrote some pseudo code how I implemented Windows style events using a mutex, condition variable and boolean flag. Is there something wrong with this code? Robin __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (2)
-
Beman Dawes
-
Robin Boerdijk