Skip to content

Commit cd466a3

Browse files
committed
Reduced average cpu usage from 7-9% to 0%
1 parent 77c1df8 commit cd466a3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/win/WinApp.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@ int RunWindowsApp ( ) { // Create the application.
5353

5454
Platform::init(); // Start the main program.
5555

56-
MSG msg {};
56+
MSG msg{};
5757
while (true) {
58-
while (PeekMessage(& msg, NULL, 0, 0, PM_REMOVE)) {
59-
TranslateMessage(& msg);
60-
DispatchMessage(& msg);
58+
DWORD result = MsgWaitForMultipleObjects(0,NULL,FALSE,1,QS_ALLINPUT);
6159

62-
if (msg.message == WM_QUIT) {
63-
Platform::shutdown(); // Exit app if quit.
64-
return 0;
60+
if (result == WAIT_OBJECT_0) {
61+
while (PeekMessage(& msg, NULL, 0, 0, PM_REMOVE)) {
62+
TranslateMessage(& msg);
63+
DispatchMessage(& msg);
64+
65+
if (msg.message == WM_QUIT) {
66+
Platform::shutdown();
67+
return 0;
68+
}
6569
}
6670
}
6771

0 commit comments

Comments
 (0)