Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: base/message_loop/message_pump_win.cc

Issue 2036603002: MessagePumpForGpu - reduce potential work processing starvation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_win.cc
diff --git a/base/message_loop/message_pump_win.cc b/base/message_loop/message_pump_win.cc
index ac54788539cb062da639e4338fe7b430c85b4449..46c4f621a3ff96a607084d4e4f601119b696865b 100644
--- a/base/message_loop/message_pump_win.cc
+++ b/base/message_loop/message_pump_win.cc
@@ -512,6 +512,12 @@ void MessagePumpForGpu::WaitForWork() {
// manager to fire the next set of timers.
int delay;
+ // TODO(stanisc): crbug.com/596190: Preserve |result| for crash dump analysis
+ // with initial value different from values returned by
+ // MsgWaitForMultipleObjectsEx.
+ DWORD result = static_cast<DWORD>(-1);
+ debug::Alias(&result);
+
// The while loop handles the situation where on Windows 7 and later versions
// MsgWaitForMultipleObjectsEx might time out slightly earlier (less than one
// ms) than the specified |delay|. In that situation it is more optimal to
@@ -520,13 +526,20 @@ void MessagePumpForGpu::WaitForWork() {
if (delay < 0) // Negative value means no timers waiting.
delay = INFINITE;
- DWORD result =
- MsgWaitForMultipleObjectsEx(1, &event_, delay, QS_ALLINPUT, 0);
+ result = MsgWaitForMultipleObjectsEx(1, &event_, delay, QS_ALLINPUT, 0);
if (result == WAIT_OBJECT_0) {
// Work available.
return;
} else if (result == WAIT_OBJECT_0 + 1) {
- // Message available. Keep waiting if this message isn't for this thread.
+ // Message available (regardless of whether |event_| is also signalled at
+ // the same time).
+
+ // Break the loop if the work is available - PeekMessage will still be
+ // called outside, in ProcessNextMessage.
+ if (WaitForSingleObject(event_, 0) == WAIT_OBJECT_0)
brucedawson 2016/06/03 00:18:30 Previously this loop would favor window messages o
+ return;
+
+ // Keep waiting if this message isn't for this thread.
MSG msg;
if (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698