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

Side by Side Diff: base/test/sequenced_worker_pool_owner.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 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
« no previous file with comments | « base/test/sequenced_worker_pool_owner.h ('k') | base/test/simple_test_clock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/test/sequenced_worker_pool_owner.h"
6
7 #include "base/location.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h"
10
11 namespace base {
12
13 SequencedWorkerPoolOwner::SequencedWorkerPoolOwner(
14 size_t max_threads,
15 const std::string& thread_name_prefix)
16 : constructor_message_loop_(MessageLoop::current()),
17 pool_(new SequencedWorkerPool(max_threads, thread_name_prefix, this)),
18 has_work_call_count_(0) {}
19
20 SequencedWorkerPoolOwner::~SequencedWorkerPoolOwner() {
21 pool_ = NULL;
22 MessageLoop::current()->Run();
23 }
24
25 const scoped_refptr<SequencedWorkerPool>& SequencedWorkerPoolOwner::pool() {
26 return pool_;
27 }
28
29 void SequencedWorkerPoolOwner::SetWillWaitForShutdownCallback(
30 const Closure& callback) {
31 will_wait_for_shutdown_callback_ = callback;
32 }
33
34 int SequencedWorkerPoolOwner::has_work_call_count() const {
35 AutoLock lock(has_work_lock_);
36 return has_work_call_count_;
37 }
38
39 void SequencedWorkerPoolOwner::OnHasWork() {
40 AutoLock lock(has_work_lock_);
41 ++has_work_call_count_;
42 }
43
44 void SequencedWorkerPoolOwner::WillWaitForShutdown() {
45 if (!will_wait_for_shutdown_callback_.is_null()) {
46 will_wait_for_shutdown_callback_.Run();
47
48 // Release the reference to the callback to prevent retain cycles.
49 will_wait_for_shutdown_callback_ = Closure();
50 }
51 }
52
53 void SequencedWorkerPoolOwner::OnDestruct() {
54 constructor_message_loop_->task_runner()->PostTask(
55 FROM_HERE, constructor_message_loop_->QuitWhenIdleClosure());
56 }
57
58 } // namespace base
OLDNEW
« no previous file with comments | « base/test/sequenced_worker_pool_owner.h ('k') | base/test/simple_test_clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698