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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Gets the worker for the current thread out of thread-local storage. | 239 // Gets the worker for the current thread out of thread-local storage. |
240 static Worker* GetForCurrentThread(); | 240 static Worker* GetForCurrentThread(); |
241 | 241 |
242 // Indicates that a task is about to be run. The parameters provide | 242 // Indicates that a task is about to be run. The parameters provide |
243 // additional metainformation about the task being run. | 243 // additional metainformation about the task being run. |
244 void set_running_task_info(SequenceToken token, | 244 void set_running_task_info(SequenceToken token, |
245 WorkerShutdown shutdown_behavior) { | 245 WorkerShutdown shutdown_behavior) { |
246 is_processing_task_ = true; | 246 is_processing_task_ = true; |
247 task_sequence_token_ = token; | 247 task_sequence_token_ = token; |
248 task_shutdown_behavior_ = shutdown_behavior; | 248 task_shutdown_behavior_ = shutdown_behavior; |
249 | |
250 // It is dangerous for tasks with CONTINUE_ON_SHUTDOWN to access a class | |
251 // that implements a non-leaky base::Singleton because they are generally | |
252 // destroyed before the process terminates via an AtExitManager | |
253 // registration. This will trigger a DCHECK to warn of such cases. See the | |
254 // comment about CONTINUE_ON_SHUTDOWN for more details. | |
255 ThreadRestrictions::SetSingletonAllowed(task_shutdown_behavior_ != | |
256 CONTINUE_ON_SHUTDOWN); | |
257 } | 249 } |
258 | 250 |
259 // Indicates that the task has finished running. | 251 // Indicates that the task has finished running. |
260 void reset_running_task_info() { is_processing_task_ = false; } | 252 void reset_running_task_info() { is_processing_task_ = false; } |
261 | 253 |
262 // Whether the worker is processing a task. | 254 // Whether the worker is processing a task. |
263 bool is_processing_task() { return is_processing_task_; } | 255 bool is_processing_task() { return is_processing_task_; } |
264 | 256 |
265 SequenceToken task_sequence_token() const { | 257 SequenceToken task_sequence_token() const { |
266 DCHECK(is_processing_task_); | 258 DCHECK(is_processing_task_); |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { | 1396 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { |
1405 DCHECK(constructor_task_runner_->BelongsToCurrentThread()); | 1397 DCHECK(constructor_task_runner_->BelongsToCurrentThread()); |
1406 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); | 1398 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); |
1407 } | 1399 } |
1408 | 1400 |
1409 bool SequencedWorkerPool::IsShutdownInProgress() { | 1401 bool SequencedWorkerPool::IsShutdownInProgress() { |
1410 return inner_->IsShutdownInProgress(); | 1402 return inner_->IsShutdownInProgress(); |
1411 } | 1403 } |
1412 | 1404 |
1413 } // namespace base | 1405 } // namespace base |
OLD | NEW |