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

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

Issue 9663075: Implementation of SequencedTaskRunner based on SequencedWorkerPool. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « base/test/sequenced_worker_pool_owner.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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.h"
9
10 namespace base {
11
12 SequencedWorkerPoolOwner::SequencedWorkerPoolOwner(
13 size_t max_threads,
14 const std::string& thread_name_prefix)
15 : constructor_message_loop_(MessageLoop::current()),
16 pool_(new SequencedWorkerPool(
17 max_threads, thread_name_prefix,
18 ALLOW_THIS_IN_INITIALIZER_LIST(this))),
19 has_work_call_count_(0) {}
20
21 SequencedWorkerPoolOwner::~SequencedWorkerPoolOwner() {
22 pool_ = NULL;
23 MessageLoop::current()->Run();
24 }
25
26 const scoped_refptr<SequencedWorkerPool>& SequencedWorkerPoolOwner::pool() {
27 return pool_;
28 }
29
30 void SequencedWorkerPoolOwner::SetWillWaitForShutdownCallback(
31 const Closure& callback) {
32 will_wait_for_shutdown_callback_ = callback;
33 }
34
35 int SequencedWorkerPoolOwner::has_work_call_count() const {
36 AutoLock lock(has_work_lock_);
37 return has_work_call_count_;
38 }
39
40 void SequencedWorkerPoolOwner::OnHasWork() {
41 AutoLock lock(has_work_lock_);
42 ++has_work_call_count_;
43 }
44
45 void SequencedWorkerPoolOwner::WillWaitForShutdown() {
46 if (!will_wait_for_shutdown_callback_.is_null()) {
47 will_wait_for_shutdown_callback_.Run();
48 }
49 }
50
51 void SequencedWorkerPoolOwner::OnDestruct() {
52 constructor_message_loop_->PostTask(
53 FROM_HERE,
54 constructor_message_loop_->QuitClosure());
55 }
56
57 } // namespace base
OLDNEW
« no previous file with comments | « base/test/sequenced_worker_pool_owner.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698