Commit e023a69e authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Avoid redundant calls to ScheduleWork

There's no need for ThreadControllerWithMessagePumpImpl::DoWork
to call ScheduleWork.  Typically it's called in a for loop, or
something equivalent.

Redundant calls to ScheduleWork are not free and show up on
profiles of SequenceManagerPerfTest.

Bug: 897751
Change-Id: Iafebf0b574d991ea3b89dfc101aa7326cd35b3c1
Reviewed-on: https://chromium-review.googlesource.com/c/1297137Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602332}
parent e3bf3a35
...@@ -153,8 +153,9 @@ bool ThreadControllerWithMessagePumpImpl::DoWork() { ...@@ -153,8 +153,9 @@ bool ThreadControllerWithMessagePumpImpl::DoWork() {
DCHECK_GE(do_work_delay, TimeDelta()); DCHECK_GE(do_work_delay, TimeDelta());
// Schedule a continuation. // Schedule a continuation.
if (do_work_delay.is_zero()) { if (do_work_delay.is_zero()) {
// Need to run new work immediately. // Need to run new work immediately, but due to the contract of DoWork we
pump_->ScheduleWork(); // only need to return true to ensure that happens.
return true;
} else if (do_work_delay != TimeDelta::Max()) { } else if (do_work_delay != TimeDelta::Max()) {
// Cancels any previously scheduled delayed wake-ups. // Cancels any previously scheduled delayed wake-ups.
pump_->ScheduleDelayedWork(lazy_now.Now() + do_work_delay); pump_->ScheduleDelayedWork(lazy_now.Now() + do_work_delay);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment