OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TOKEN_H_ | 5 #ifndef BASE_SEQUENCE_TOKEN_H_ |
6 #define BASE_SEQUENCE_TOKEN_H_ | 6 #define BASE_SEQUENCE_TOKEN_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Returns a valid SequenceToken which isn't equal to any previously returned | 32 // Returns a valid SequenceToken which isn't equal to any previously returned |
33 // SequenceToken. | 33 // SequenceToken. |
34 static SequenceToken Create(); | 34 static SequenceToken Create(); |
35 | 35 |
36 // Returns the SequenceToken associated with the task running on the current | 36 // Returns the SequenceToken associated with the task running on the current |
37 // thread, as determined by the active ScopedSetSequenceTokenForCurrentThread | 37 // thread, as determined by the active ScopedSetSequenceTokenForCurrentThread |
38 // if any. | 38 // if any. |
39 static SequenceToken GetForCurrentThread(); | 39 static SequenceToken GetForCurrentThread(); |
40 | 40 |
41 private: | 41 private: |
42 SequenceToken(int token) : token_(token) {} | 42 explicit SequenceToken(int token) : token_(token) {} |
43 | 43 |
44 static constexpr int kInvalidSequenceToken = -1; | 44 static constexpr int kInvalidSequenceToken = -1; |
45 int token_ = kInvalidSequenceToken; | 45 int token_ = kInvalidSequenceToken; |
46 }; | 46 }; |
47 | 47 |
48 // A token that identifies a task. | 48 // A token that identifies a task. |
49 // | 49 // |
50 // This is used by ThreadCheckerImpl to determine whether calls to | 50 // This is used by ThreadCheckerImpl to determine whether calls to |
51 // CalledOnValidThread() come from the same task and hence are deterministically | 51 // CalledOnValidThread() come from the same task and hence are deterministically |
52 // single-threaded (vs. calls coming from different sequenced or parallel tasks, | 52 // single-threaded (vs. calls coming from different sequenced or parallel tasks, |
(...skipping 17 matching lines...) Expand all Loading... |
70 | 70 |
71 // In the scope of a ScopedSetSequenceTokenForCurrentThread, returns a valid | 71 // In the scope of a ScopedSetSequenceTokenForCurrentThread, returns a valid |
72 // TaskToken which isn't equal to any TaskToken returned in the scope of a | 72 // TaskToken which isn't equal to any TaskToken returned in the scope of a |
73 // different ScopedSetSequenceTokenForCurrentThread. Otherwise, returns an | 73 // different ScopedSetSequenceTokenForCurrentThread. Otherwise, returns an |
74 // invalid TaskToken. | 74 // invalid TaskToken. |
75 static TaskToken GetForCurrentThread(); | 75 static TaskToken GetForCurrentThread(); |
76 | 76 |
77 private: | 77 private: |
78 friend class ScopedSetSequenceTokenForCurrentThread; | 78 friend class ScopedSetSequenceTokenForCurrentThread; |
79 | 79 |
80 TaskToken(int token) : token_(token) {} | 80 explicit TaskToken(int token) : token_(token) {} |
81 | 81 |
82 // Returns a valid TaskToken which isn't equal to any previously returned | 82 // Returns a valid TaskToken which isn't equal to any previously returned |
83 // TaskToken. This is private as it only meant to be instantiated by | 83 // TaskToken. This is private as it only meant to be instantiated by |
84 // ScopedSetSequenceTokenForCurrentThread. | 84 // ScopedSetSequenceTokenForCurrentThread. |
85 static TaskToken Create(); | 85 static TaskToken Create(); |
86 | 86 |
87 static constexpr int kInvalidTaskToken = -1; | 87 static constexpr int kInvalidTaskToken = -1; |
88 int token_ = kInvalidTaskToken; | 88 int token_ = kInvalidTaskToken; |
89 }; | 89 }; |
90 | 90 |
(...skipping 11 matching lines...) Expand all Loading... |
102 private: | 102 private: |
103 const SequenceToken sequence_token_; | 103 const SequenceToken sequence_token_; |
104 const TaskToken task_token_; | 104 const TaskToken task_token_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(ScopedSetSequenceTokenForCurrentThread); | 106 DISALLOW_COPY_AND_ASSIGN(ScopedSetSequenceTokenForCurrentThread); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace base | 109 } // namespace base |
110 | 110 |
111 #endif // BASE_SEQUENCE_TOKEN_H_ | 111 #endif // BASE_SEQUENCE_TOKEN_H_ |
OLD | NEW |