Skip to content

Commit

Permalink
platform: fix usage of Win32 function Sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed Oct 21, 2024
1 parent 714eb0b commit 1541082
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/platform/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,19 @@ static void pollHandles(PollData &pd, int ms) noexcept
{
auto &handles = pd.handles;
auto &states = pd.states;
DWORD timeout = ms < 0 ? INFINITE : ms;
if (handles.size() == 0)
Sleep(ms);
Sleep(timeout);
else
{
DWORD res = WaitForMultipleObjects(
handles.size(), &handles[0], FALSE, (ms < 0 ? INFINITE : ms));
DWORD res = WaitForMultipleObjects(handles.size(), &handles[0], false, timeout);
size_t i = 0;
while (WAIT_OBJECT_0 <= res && res <= WAIT_OBJECT_0 + handles.size() - i - 1)
{
i += res - WAIT_OBJECT_0;
states[i] = psReady;
if (++i < handles.size())
// Isn't this awful?
res = WaitForMultipleObjects(
handles.size() - i, &handles[i], FALSE, 0);
res = WaitForMultipleObjects(handles.size() - i, &handles[i], false, 0);
else
break;
}
Expand Down

0 comments on commit 1541082

Please sign in to comment.