Skip to content

Commit

Permalink
Make WaitForMultipleEvents atomic when waitAll is true
Browse files Browse the repository at this point in the history
This patch significantly changes the behavior (and to an extent, the
performance) of pevents to more closely mimic the documented behavior of
`WaitForMultipleObjects` and `WaitForMultipleObjectsEx`.

As reported in #9, the previous behavior did not make any atomicity
guarantees when a call to `WaitForMultipleEvents()` was made with
`waitAll = true`, and WFME would attempt to serially obtain the events
in question, which could lead to a deadlock in case of circular locking
and auto-reset events.

The WFMO behavior documented on MSDN makes it clear that the Windows
implementation does not modify the signalled state of any of the manual
or auto reset events being awaited until the WFMO call is ready to
return, at which point either the one event in question or all the
events being awaited (dependent on `waitAll`) are atomically awaited.
  • Loading branch information
mqudsi committed Jun 28, 2021
1 parent 21aef2d commit 2db23ff
Showing 1 changed file with 179 additions and 133 deletions.
Loading

0 comments on commit 2db23ff

Please sign in to comment.