Skip to content

Commit

Permalink
[AOT] Fix CPU consumption (#19653)
Browse files Browse the repository at this point in the history
Wait until object is signaled instead
  • Loading branch information
stefansjfw committed Jul 28, 2022
1 parent 9fb9c6a commit bdddea9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ AlwaysOnTop::AlwaysOnTop(bool useLLKH) :

AlwaysOnTop::~AlwaysOnTop()
{
m_running = false;

if (m_hPinEvent)
{
// Needed to unblock MsgWaitForMultipleObjects one last time
SetEvent(m_hPinEvent);
CloseHandle(m_hPinEvent);
}

m_running = false;
m_thread.join();

CleanUp();
Expand Down Expand Up @@ -280,7 +282,11 @@ void AlwaysOnTop::RegisterLLKH()
MSG msg;
while (m_running)
{
DWORD dwEvt = MsgWaitForMultipleObjects(1, &m_hPinEvent, false, 0, QS_ALLINPUT);
DWORD dwEvt = MsgWaitForMultipleObjects(1, &m_hPinEvent, false, INFINITE, QS_ALLINPUT);
if (!m_running)
{
break;
}
switch (dwEvt)
{
case WAIT_OBJECT_0:
Expand Down

0 comments on commit bdddea9

Please sign in to comment.