OLD | NEW |
---|---|
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 Loading... | |
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 DCHECK_EQ(delay_ms, 0); | |
153 return PostWorkerTask(from_here, task); | |
154 } | |
155 | |
156 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const { | |
157 // TODO(akalin): Add support for this. | |
brettw
2012/02/24 05:25:51
Can you clarify what this comment is trying to say
willchan no longer on Chromium
2012/02/28 22:29:54
I think we don't want people to call this function
akalin
2012/02/29 00:17:42
Clarified comment. I think I agree with willchan
| |
158 NOTREACHED(); | |
159 return true; | |
160 } | |
161 | |
148 void SequencedWorkerPool::FlushForTesting() { | 162 void SequencedWorkerPool::FlushForTesting() { |
149 { | 163 { |
150 AutoLock lock(lock_); | 164 AutoLock lock(lock_); |
151 while (pending_task_count_ > 0 || waiting_thread_count_ < threads_.size()) | 165 while (pending_task_count_ > 0 || waiting_thread_count_ < threads_.size()) |
152 cond_var_.Wait(); | 166 cond_var_.Wait(); |
153 } | 167 } |
154 cond_var_.Signal(); | 168 cond_var_.Signal(); |
155 } | 169 } |
156 | 170 |
157 void SequencedWorkerPool::Shutdown() { | 171 void SequencedWorkerPool::Shutdown() { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 | 509 |
496 bool SequencedWorkerPool::CanShutdown() const { | 510 bool SequencedWorkerPool::CanShutdown() const { |
497 lock_.AssertAcquired(); | 511 lock_.AssertAcquired(); |
498 // See PrepareToStartAdditionalThreadIfHelpful for how thread creation works. | 512 // See PrepareToStartAdditionalThreadIfHelpful for how thread creation works. |
499 return !thread_being_created_ && | 513 return !thread_being_created_ && |
500 blocking_shutdown_thread_count_ == 0 && | 514 blocking_shutdown_thread_count_ == 0 && |
501 blocking_shutdown_pending_task_count_ == 0; | 515 blocking_shutdown_pending_task_count_ == 0; |
502 } | 516 } |
503 | 517 |
504 } // namespace base | 518 } // namespace base |
OLD | NEW |