From e5f56a004e0df9151d0ae1ca0565eabc761f00a6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 21 Nov 2000 17:22:03 +0000 Subject: [PATCH] fixed bug with Broadcast() not waking up all threads (Pieter van der Meulen) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/thread.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 66efdf36ac..a743d287b0 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -257,10 +257,15 @@ public: void Broadcast() { + // we need to save the original value as m_nWaiters is goign to be + // decreased by the signalled thread resulting in the loop being + // executed less times than needed + LONG nWaiters = m_nWaiters; + // this works because all these threads are already waiting and so each // SetEvent() inside Signal() is really a PulseEvent() because the // event state is immediately returned to non-signaled - for ( LONG n = 0; n < m_nWaiters; n++ ) + for ( LONG n = 0; n < nWaiters; n++ ) { Signal(); } -- 2.45.2