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

Side by Side Diff: base/sequence_checker_impl.h

Issue 2690533002: Remove header dependencies from sequence_checker.h to sequenced_worker_pool.h (Closed)
Patch Set: rebase Created 3 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
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 #ifndef BASE_SEQUENCE_CHECKER_IMPL_H_ 5 #ifndef BASE_SEQUENCE_CHECKER_IMPL_H_
6 #define BASE_SEQUENCE_CHECKER_IMPL_H_ 6 #define BASE_SEQUENCE_CHECKER_IMPL_H_
7 7
8 #include <memory>
9
8 #include "base/base_export.h" 10 #include "base/base_export.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/sequence_token.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/threading/thread_checker_impl.h"
15 14
16 namespace base { 15 namespace base {
17 16
18 // Real implementation of SequenceChecker for use in debug mode or for temporary 17 // Real implementation of SequenceChecker for use in debug mode or for temporary
19 // use in release mode (e.g. to CHECK on a threading issue seen only in the 18 // use in release mode (e.g. to CHECK on a threading issue seen only in the
20 // wild). 19 // wild).
21 // 20 //
22 // Note: You should almost always use the SequenceChecker class to get the right 21 // Note: You should almost always use the SequenceChecker class to get the right
23 // version for your build configuration. 22 // version for your build configuration.
24 class BASE_EXPORT SequenceCheckerImpl { 23 class BASE_EXPORT SequenceCheckerImpl {
25 public: 24 public:
26 SequenceCheckerImpl(); 25 SequenceCheckerImpl();
27 ~SequenceCheckerImpl(); 26 ~SequenceCheckerImpl();
28 27
29 // Returns true if called in sequence with previous calls to this method and 28 // Returns true if called in sequence with previous calls to this method and
30 // the constructor. 29 // the constructor.
31 bool CalledOnValidSequence() const WARN_UNUSED_RESULT; 30 bool CalledOnValidSequence() const WARN_UNUSED_RESULT;
32 31
33 // Unbinds the checker from the currently associated sequence. The checker 32 // Unbinds the checker from the currently associated sequence. The checker
34 // will be re-bound on the next call to CalledOnValidSequence(). 33 // will be re-bound on the next call to CalledOnValidSequence().
35 void DetachFromSequence(); 34 void DetachFromSequence();
36 35
37 private: 36 private:
37 class Core;
38
38 void EnsureSequenceTokenAssigned() const; 39 void EnsureSequenceTokenAssigned() const;
39 40
40 // Guards all variables below. 41 // Guards all variables below.
41 mutable Lock lock_; 42 mutable Lock lock_;
42 43 mutable std::unique_ptr<Core> core_;
43 // True when the SequenceChecker is bound to a sequence or a thread.
44 mutable bool is_assigned_ = false;
45
46 mutable SequenceToken sequence_token_;
47
48 // TODO(gab): Remove this when SequencedWorkerPool is deprecated in favor of
49 // TaskScheduler. crbug.com/622400
50 mutable SequencedWorkerPool::SequenceToken sequenced_worker_pool_token_;
51
52 // Used when |sequenced_worker_pool_token_| and |sequence_token_| are invalid.
53 ThreadCheckerImpl thread_checker_;
54 44
55 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl); 45 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
56 }; 46 };
57 47
58 } // namespace base 48 } // namespace base
59 49
60 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_ 50 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | base/sequence_checker_impl.cc » ('j') | base/sequence_checker_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698