Skip to content

Commit

Permalink
Fix excessive CPU usage with external and multi-threaded message loop…
Browse files Browse the repository at this point in the history
…s (fixes issue chromiumembedded#2809, fixes issue chromiumembedded#2970).
  • Loading branch information
masakotoda authored and magreenblatt committed Jul 21, 2020
1 parent a8731e7 commit 7448470
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libcef/browser/browser_message_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,21 @@ class MessagePumpExternal : public base::MessagePumpForUI {
// is_immediate() returns true if the next task is ready right away.
more_immediate_work = next_work_info.is_immediate();
if (!more_immediate_work) {
// DoIdleWork() returns true if idle work was all done.
more_idle_work = !delegate->DoIdleWork();

// Check the next PendingTask's |delayed_run_time|.
// is_max() returns true if there are no more immediate nor delayed tasks.
more_delayed_work = !next_work_info.delayed_run_time.is_max();
if (more_delayed_work && !more_idle_work) {
if (more_delayed_work) {
// The only remaining work that we know about is the PendingTask.
// Consider the run time for that task in the time slice calculation.
*next_run_time = next_work_info.delayed_run_time;
}
}

if (!more_immediate_work && !more_delayed_work) {
// DoIdleWork() returns true if idle work was all done.
more_idle_work = !delegate->DoIdleWork();
}

return more_immediate_work || more_idle_work || more_delayed_work;
}

Expand Down

0 comments on commit 7448470

Please # to comment.