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

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 9401032: Make SequencedWorkerPool a TaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated with changes from 9347056 Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
10 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
11 #include "base/threading/simple_thread.h" 10 #include "base/threading/simple_thread.h"
12 #include "base/time.h" 11 #include "base/time.h"
13 12
14 namespace base { 13 namespace base {
15 14
16 // Worker --------------------------------------------------------------------- 15 // Worker ---------------------------------------------------------------------
17 16
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 bool SequencedWorkerPool::PostSequencedWorkerTaskWithShutdownBehavior( 138 bool SequencedWorkerPool::PostSequencedWorkerTaskWithShutdownBehavior(
140 SequenceToken sequence_token, 139 SequenceToken sequence_token,
141 const tracked_objects::Location& from_here, 140 const tracked_objects::Location& from_here,
142 const Closure& task, 141 const Closure& task,
143 WorkerShutdown shutdown_behavior) { 142 WorkerShutdown shutdown_behavior) {
144 return PostTaskHelper(NULL, sequence_token, shutdown_behavior, 143 return PostTaskHelper(NULL, sequence_token, shutdown_behavior,
145 from_here, task); 144 from_here, task);
146 } 145 }
147 146
147 bool SequencedWorkerPool::PostDelayedTask(
148 const tracked_objects::Location& from_here,
149 const Closure& task,
150 int64 delay_ms) {
151 // TODO(akalin): Add support for non-zero delays.
152 DLOG_IF(WARNING, delay_ms > 0) << "Ignoring delay of " << delay_ms << " ms";
willchan no longer on Chromium 2012/02/23 19:39:57 I suggest NOTREACHED() instead. If this starts hap
akalin 2012/02/23 22:52:21 Done. Used DCHECK_EQ instead of NOTREACHED(). Ad
153 return PostWorkerTask(from_here, task);
154 }
155
156 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const {
157 // TODO(akalin): Add support for this.
willchan no longer on Chromium 2012/02/23 19:39:57 When is this coming? Do not land without it, or us
akalin 2012/02/23 22:52:21 Use NOTREACHED(). I'll see if I can implement thi
158 return true;
159 }
160
148 void SequencedWorkerPool::FlushForTesting() { 161 void SequencedWorkerPool::FlushForTesting() {
149 { 162 {
150 AutoLock lock(lock_); 163 AutoLock lock(lock_);
151 while (pending_task_count_ > 0 || waiting_thread_count_ < threads_.size()) 164 while (pending_task_count_ > 0 || waiting_thread_count_ < threads_.size())
152 cond_var_.Wait(); 165 cond_var_.Wait();
153 } 166 }
154 cond_var_.Signal(); 167 cond_var_.Signal();
155 } 168 }
156 169
157 void SequencedWorkerPool::Shutdown() { 170 void SequencedWorkerPool::Shutdown() {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 508
496 bool SequencedWorkerPool::CanShutdown() const { 509 bool SequencedWorkerPool::CanShutdown() const {
497 lock_.AssertAcquired(); 510 lock_.AssertAcquired();
498 // See PrepareToStartAdditionalThreadIfHelpful for how thread creation works. 511 // See PrepareToStartAdditionalThreadIfHelpful for how thread creation works.
499 return !thread_being_created_ && 512 return !thread_being_created_ &&
500 blocking_shutdown_thread_count_ == 0 && 513 blocking_shutdown_thread_count_ == 0 &&
501 blocking_shutdown_pending_task_count_ == 0; 514 blocking_shutdown_pending_task_count_ == 0;
502 } 515 }
503 516
504 } // namespace base 517 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698