blob: a54c38845114b15a1e78ff097ad116b55d29cb82 [file] [log] [blame]
[email protected]399ed422012-12-27 19:58:001// 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_SEQUENCE_CHECKER_IMPL_H_
6#define BASE_SEQUENCE_CHECKER_IMPL_H_
7
tzik0c2fcf52017-02-16 08:52:318#include <memory>
9
[email protected]399ed422012-12-27 19:58:0010#include "base/base_export.h"
fdorayeed5fa72016-07-26 22:28:4511#include "base/compiler_specific.h"
avi9b6f42932015-12-26 22:15:1412#include "base/macros.h"
[email protected]399ed422012-12-27 19:58:0013#include "base/synchronization/lock.h"
[email protected]399ed422012-12-27 19:58:0014
15namespace base {
16
fdorayeed5fa72016-07-26 22:28:4517// Real implementation of SequenceChecker for use in debug mode or for temporary
18// use in release mode (e.g. to CHECK on a threading issue seen only in the
19// wild).
20//
21// Note: You should almost always use the SequenceChecker class to get the right
22// version for your build configuration.
[email protected]399ed422012-12-27 19:58:0023class BASE_EXPORT SequenceCheckerImpl {
24 public:
[email protected]d52426c2013-07-30 19:26:4025 SequenceCheckerImpl();
[email protected]399ed422012-12-27 19:58:0026 ~SequenceCheckerImpl();
27
fdorayeed5fa72016-07-26 22:28:4528 // Returns true if called in sequence with previous calls to this method and
29 // the constructor.
fdoraye2b19a12016-07-29 02:30:1630 bool CalledOnValidSequence() const WARN_UNUSED_RESULT;
[email protected]399ed422012-12-27 19:58:0031
fdorayeed5fa72016-07-26 22:28:4532 // Unbinds the checker from the currently associated sequence. The checker
fdoraye2b19a12016-07-29 02:30:1633 // will be re-bound on the next call to CalledOnValidSequence().
[email protected]d52426c2013-07-30 19:26:4034 void DetachFromSequence();
[email protected]399ed422012-12-27 19:58:0035
36 private:
tzik0c2fcf52017-02-16 08:52:3137 class Core;
[email protected]d52426c2013-07-30 19:26:4038
[email protected]399ed422012-12-27 19:58:0039 // Guards all variables below.
40 mutable Lock lock_;
tzik0c2fcf52017-02-16 08:52:3141 mutable std::unique_ptr<Core> core_;
[email protected]399ed422012-12-27 19:58:0042
43 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
44};
45
46} // namespace base
47
48#endif // BASE_SEQUENCE_CHECKER_IMPL_H_