|
OLD | NEW |
---|---|
(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 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | |
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | |
akalin
2012/03/20 22:16:08
i think it's better to put this in a new file sequ
Francois
2012/03/26 09:33:21
Done.
| |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/synchronization/lock.h" | |
12 #include "base/threading/sequenced_worker_pool.h" | |
13 | |
14 class MessageLoop; | |
15 | |
16 namespace base { | |
17 | |
18 // Wrapper around SequencedWorkerPool that blocks destruction until | |
akalin
2012/03/20 22:16:08
SequencedWorkerPool that -> SequencedWorkerPool fo
Francois
2012/03/26 09:33:21
Done.
| |
19 // the pool is actually destroyed. This is so that a | |
20 // SequencedWorkerPool from one test doesn't outlive its test and | |
21 // cause strange races with other tests that touch global stuff (like | |
22 // histograms and logging). However, this requires that nothing else | |
23 // on this thread holds a ref to the pool when the | |
24 // SequencedWorkerPoolOwner is destroyed. | |
25 class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver { | |
26 public: | |
27 SequencedWorkerPoolOwner(size_t max_threads, | |
28 const std::string& thread_name_prefix); | |
29 | |
30 virtual ~SequencedWorkerPoolOwner(); | |
31 | |
32 // Don't change the return pool's testing observer. | |
akalin
2012/03/20 22:16:08
return -> returned
Francois
2012/03/26 09:33:21
Done.
| |
33 const scoped_refptr<SequencedWorkerPool>& pool(); | |
34 | |
35 // The given callback will be called on WillWaitForShutdown(). | |
36 void SetWillWaitForShutdownCallback(const Closure& callback); | |
37 | |
38 int has_work_call_count() const; | |
39 | |
40 private: | |
41 // SequencedWorkerPool::TestingObserver implementation. | |
42 virtual void OnHasWork() OVERRIDE; | |
akalin
2012/03/20 22:16:08
need compiler_specific.h include for this
Francois
2012/03/26 09:33:21
Done.
| |
43 virtual void WillWaitForShutdown() OVERRIDE; | |
44 virtual void OnDestruct() OVERRIDE; | |
45 | |
46 MessageLoop* const constructor_message_loop_; | |
47 scoped_refptr<SequencedWorkerPool> pool_; | |
akalin
2012/03/20 22:16:08
need base/memory/ref_counted.h include for this
Francois
2012/03/26 09:33:21
Done.
| |
48 Closure will_wait_for_shutdown_callback_; | |
49 | |
50 mutable Lock has_work_lock_; | |
51 int has_work_call_count_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolOwner); | |
akalin
2012/03/20 22:16:08
need #include "base/basictypes.h" for this
Francois
2012/03/26 09:33:21
Done.
| |
54 }; | |
55 | |
56 } // namespace base | |
57 | |
58 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | |
OLD | NEW |