OLD | NEW |
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 "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // | 21 // |
22 // Note: You should almost always use the SequenceChecker class to get the right | 22 // Note: You should almost always use the SequenceChecker class to get the right |
23 // version for your build configuration. | 23 // version for your build configuration. |
24 class BASE_EXPORT SequenceCheckerImpl { | 24 class BASE_EXPORT SequenceCheckerImpl { |
25 public: | 25 public: |
26 SequenceCheckerImpl(); | 26 SequenceCheckerImpl(); |
27 ~SequenceCheckerImpl(); | 27 ~SequenceCheckerImpl(); |
28 | 28 |
29 // Returns true if called in sequence with previous calls to this method and | 29 // Returns true if called in sequence with previous calls to this method and |
30 // the constructor. | 30 // the constructor. |
31 bool CalledOnValidSequencedThread() const WARN_UNUSED_RESULT; | 31 bool CalledOnValidSequence() const WARN_UNUSED_RESULT; |
32 | 32 |
33 // Unbinds the checker from the currently associated sequence. The checker | 33 // Unbinds the checker from the currently associated sequence. The checker |
34 // will be re-bound on the next call to CalledOnValidSequencedThread(). | 34 // will be re-bound on the next call to CalledOnValidSequence(). |
35 void DetachFromSequence(); | 35 void DetachFromSequence(); |
36 | 36 |
37 private: | 37 private: |
38 void EnsureSequenceTokenAssigned() const; | 38 void EnsureSequenceTokenAssigned() const; |
39 | 39 |
40 // Guards all variables below. | 40 // Guards all variables below. |
41 mutable Lock lock_; | 41 mutable Lock lock_; |
42 | 42 |
43 // True when the SequenceChecker is bound to a sequence or a thread. | 43 // True when the SequenceChecker is bound to a sequence or a thread. |
44 mutable bool is_assigned_ = false; | 44 mutable bool is_assigned_ = false; |
45 | 45 |
46 mutable SequenceToken sequence_token_; | 46 mutable SequenceToken sequence_token_; |
47 | 47 |
48 // TODO(gab): Remove this when SequencedWorkerPool is deprecated in favor of | 48 // TODO(gab): Remove this when SequencedWorkerPool is deprecated in favor of |
49 // TaskScheduler. crbug.com/622400 | 49 // TaskScheduler. crbug.com/622400 |
50 mutable SequencedWorkerPool::SequenceToken sequenced_worker_pool_token_; | 50 mutable SequencedWorkerPool::SequenceToken sequenced_worker_pool_token_; |
51 | 51 |
52 // Used when |sequenced_worker_pool_token_| and |sequence_token_| are invalid. | 52 // Used when |sequenced_worker_pool_token_| and |sequence_token_| are invalid. |
53 ThreadCheckerImpl thread_checker_; | 53 ThreadCheckerImpl thread_checker_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl); | 55 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl); |
56 }; | 56 }; |
57 | 57 |
58 } // namespace base | 58 } // namespace base |
59 | 59 |
60 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_ | 60 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_ |
OLD | NEW |