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

Unified Diff: base/task_scheduler/scheduler_worker.cc

Issue 2762703002: FOR REFERENCE ONLY Task Scheduler COM Task Runner (Closed)
Patch Set: Created 3 years, 9 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 | « base/task_scheduler/scheduler_worker.h ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker.cc
diff --git a/base/task_scheduler/scheduler_worker.cc b/base/task_scheduler/scheduler_worker.cc
index 3f371887d511454e648054c7bf98d3255ee3ce20..ec7ff0e3cc75a7505429e7d1dc18509d8695aefc 100644
--- a/base/task_scheduler/scheduler_worker.cc
+++ b/base/task_scheduler/scheduler_worker.cc
@@ -41,7 +41,7 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate {
outer_->delegate_->OnMainEntry(outer_.get());
// A SchedulerWorker starts out waiting for work.
- WaitForWork();
+ outer_->delegate_->WaitForWork(&wake_up_event_);
#if defined(OS_WIN)
std::unique_ptr<win::ScopedCOMInitializer> com_initializer;
@@ -72,7 +72,7 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate {
break;
}
}
- WaitForWork();
+ outer_->delegate_->WaitForWork(&wake_up_event_);
continue;
}
@@ -143,19 +143,6 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate {
current_thread_priority_);
}
- void WaitForWork() {
- DCHECK(outer_);
- const TimeDelta sleep_time = outer_->delegate_->GetSleepTimeout();
- if (sleep_time.is_max()) {
- // Calling TimedWait with TimeDelta::Max is not recommended per
- // http://crbug.com/465948.
- wake_up_event_.Wait();
- } else {
- wake_up_event_.TimedWait(sleep_time);
- }
- wake_up_event_.Reset();
- }
-
// Returns the priority for which the thread should be set based on the
// priority hint, current shutdown state, and platform capabilities.
ThreadPriority GetDesiredThreadPriority() {
@@ -201,6 +188,19 @@ class SchedulerWorker::Thread : public PlatformThread::Delegate {
DISALLOW_COPY_AND_ASSIGN(Thread);
};
+void SchedulerWorker::Delegate::WaitForWork(WaitableEvent* wake_up_event) {
+ DCHECK(wake_up_event);
+ const TimeDelta sleep_time = GetSleepTimeout();
+ if (sleep_time.is_max()) {
+ // Calling TimedWait with TimeDelta::Max is not recommended per
+ // http://crbug.com/465948.
+ wake_up_event->Wait();
+ } else {
+ wake_up_event->TimedWait(sleep_time);
+ }
+ wake_up_event->Reset();
+}
+
scoped_refptr<SchedulerWorker> SchedulerWorker::Create(
ThreadPriority priority_hint,
std::unique_ptr<Delegate> delegate,
« no previous file with comments | « base/task_scheduler/scheduler_worker.h ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698