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

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

Issue 10829318: Make sure that shutdown blocking SequencedWorkerPool use Critical Closures. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/critical_closure.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
18 #include "base/message_loop_proxy.h" 19 #include "base/message_loop_proxy.h"
19 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
20 #include "base/stl_util.h" 21 #include "base/stl_util.h"
21 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
22 #include "base/synchronization/condition_variable.h" 23 #include "base/synchronization/condition_variable.h"
23 #include "base/synchronization/lock.h" 24 #include "base/synchronization/lock.h"
24 #include "base/threading/platform_thread.h" 25 #include "base/threading/platform_thread.h"
25 #include "base/threading/simple_thread.h" 26 #include "base/threading/simple_thread.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 bool SequencedWorkerPool::Inner::PostTask( 484 bool SequencedWorkerPool::Inner::PostTask(
484 const std::string* optional_token_name, 485 const std::string* optional_token_name,
485 SequenceToken sequence_token, 486 SequenceToken sequence_token,
486 WorkerShutdown shutdown_behavior, 487 WorkerShutdown shutdown_behavior,
487 const tracked_objects::Location& from_here, 488 const tracked_objects::Location& from_here,
488 const Closure& task) { 489 const Closure& task) {
489 SequencedTask sequenced(from_here); 490 SequencedTask sequenced(from_here);
490 sequenced.sequence_token_id = sequence_token.id_; 491 sequenced.sequence_token_id = sequence_token.id_;
491 sequenced.shutdown_behavior = shutdown_behavior; 492 sequenced.shutdown_behavior = shutdown_behavior;
492 sequenced.posted_from = from_here; 493 sequenced.posted_from = from_here;
493 sequenced.task = task; 494 sequenced.task =
495 shutdown_behavior == BLOCK_SHUTDOWN ?
496 base::MakeCriticalClosure(task) : task;
494 497
495 int create_thread_id = 0; 498 int create_thread_id = 0;
496 { 499 {
497 AutoLock lock(lock_); 500 AutoLock lock(lock_);
498 if (shutdown_called_) 501 if (shutdown_called_)
499 return false; 502 return false;
500 503
501 // Now that we have the lock, apply the named token rules. 504 // Now that we have the lock, apply the named token rules.
502 if (optional_token_name) 505 if (optional_token_name)
503 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name); 506 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 void SequencedWorkerPool::SignalHasWorkForTesting() { 1015 void SequencedWorkerPool::SignalHasWorkForTesting() {
1013 inner_->SignalHasWorkForTesting(); 1016 inner_->SignalHasWorkForTesting();
1014 } 1017 }
1015 1018
1016 void SequencedWorkerPool::Shutdown() { 1019 void SequencedWorkerPool::Shutdown() {
1017 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1020 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1018 inner_->Shutdown(); 1021 inner_->Shutdown();
1019 } 1022 }
1020 1023
1021 } // namespace base 1024 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698