From 1daad02c15f18684eaaea016c98383e433d9279e Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 7 Jul 2021 22:59:07 -0500 Subject: [PATCH] fixup! Make `WaitForMultipleEvents` atomic when `waitAll` is true --- src/pevents.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pevents.cpp b/src/pevents.cpp index 70c1457..ae2ab94 100644 --- a/src/pevents.cpp +++ b/src/pevents.cpp @@ -446,6 +446,12 @@ namespace neosmart { consumed = true; } + // Explictly set `StillWaiting` to false ourselves rather than waiting for the + // waiter to do it so another `SetEvent()` on a different autoreset event also + // being awaited by the same waiter isn't also consumed if scheduled before the + // waiter gets around to setting StillWaiting to false. + i->Waiter->StillWaiting = false; + result = pthread_cond_signal(&i->Waiter->CVariable); assert(result == 0); }