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

Unified Diff: base/sequence_checker_impl.h

Issue 2165663003: TaskScheduler: Add SequenceToken and ScopedSetSequenceTokenForCurrentThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-review Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: base/sequence_checker_impl.h
diff --git a/base/sequence_checker_impl.h b/base/sequence_checker_impl.h
index e3c5fed508c433c60ed9e0b31db4fafc54e5d12b..8e2c06376739d75b394c41a558455dd636fc17ff 100644
--- a/base/sequence_checker_impl.h
+++ b/base/sequence_checker_impl.h
@@ -6,30 +6,32 @@
#define BASE_SEQUENCE_CHECKER_IMPL_H_
#include "base/base_export.h"
+#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/sequence_token.h"
#include "base/synchronization/lock.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker_impl.h"
namespace base {
-// SequenceCheckerImpl is used to help verify that some methods of a
-// class are called in sequence -- that is, called from the same
-// SequencedTaskRunner. It is a generalization of ThreadChecker; in
-// particular, it behaves exactly like ThreadChecker if constructed
-// on a thread that is not part of a SequencedWorkerPool.
+// Real implementation of SequenceChecker for use in debug mode or for temporary
+// use in release mode (e.g. to CHECK on a threading issue seen only in the
+// wild).
+//
+// Note: You should almost always use the SequenceChecker class to get the right
+// version for your build configuration.
class BASE_EXPORT SequenceCheckerImpl {
public:
SequenceCheckerImpl();
~SequenceCheckerImpl();
- // Returns whether the we are being called on the same sequence token
- // as previous calls. If there is no associated sequence, then returns
- // whether we are being called on the underlying ThreadChecker's thread.
- bool CalledOnValidSequencedThread() const;
+ // Returns true if called in sequence with previous calls to this method and
+ // the constructor.
+ bool CalledOnValidSequencedThread() const WARN_UNUSED_RESULT;
- // Unbinds the checker from the currently associated sequence. The
- // checker will be re-bound on the next call to CalledOnValidSequence().
+ // Unbinds the checker from the currently associated sequence. The checker
+ // will be re-bound on the next call to CalledOnValidSequencedThread().
void DetachFromSequence();
private:
@@ -38,11 +40,17 @@ class BASE_EXPORT SequenceCheckerImpl {
// Guards all variables below.
mutable Lock lock_;
- // Used if |sequence_token_| is not valid.
- ThreadCheckerImpl thread_checker_;
- mutable bool sequence_token_assigned_;
+ // True when the SequenceChecker is bound to a sequence or a thread.
+ mutable bool is_assigned_ = false;
+
+ mutable SequenceToken sequence_token_;
- mutable SequencedWorkerPool::SequenceToken sequence_token_;
+ // TODO(gab): Remove this when SequencedWorkerPool is deprecated in favor of
+ // TaskScheduler. crbug.com/622400
+ mutable SequencedWorkerPool::SequenceToken sequenced_worker_pool_token_;
+
+ // Used when |sequenced_worker_pool_token_| and |sequence_token_| are invalid.
+ ThreadCheckerImpl thread_checker_;
DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
};

Powered by Google App Engine
This is Rietveld 408576698