LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/base - sequenced_task_checker.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #ifndef WEBRTC_BASE_SEQUENCED_TASK_CHECKER_H_
      12             : #define WEBRTC_BASE_SEQUENCED_TASK_CHECKER_H_
      13             : 
      14             : // Apart from debug builds, we also enable the sequence checker in
      15             : // builds with RTC_DCHECK_IS_ON so that trybots and waterfall bots
      16             : // with this define will get the same level of checking as debug bots.
      17             : #define ENABLE_SEQUENCED_TASK_CHECKER RTC_DCHECK_IS_ON
      18             : 
      19             : #include "webrtc/base/checks.h"
      20             : #include "webrtc/base/constructormagic.h"
      21             : #include "webrtc/base/thread_annotations.h"
      22             : #include "webrtc/base/sequenced_task_checker_impl.h"
      23             : 
      24             : namespace rtc {
      25             : 
      26             : // Do nothing implementation, for use in release mode.
      27             : //
      28             : // Note: You should almost always use the SequencedTaskChecker class to get the
      29             : // right version for your build configuration.
      30             : class SequencedTaskCheckerDoNothing {
      31             :  public:
      32             :   bool CalledSequentially() const { return true; }
      33             : 
      34             :   void Detach() {}
      35             : };
      36             : 
      37             : // SequencedTaskChecker is a helper class used to help verify that some methods
      38             : // of a class are called on the same task queue or thread. A
      39             : // SequencedTaskChecker is bound to a a task queue if the object is
      40             : // created on a task queue, or a thread otherwise.
      41             : //
      42             : //
      43             : // Example:
      44             : // class MyClass {
      45             : //  public:
      46             : //   void Foo() {
      47             : //     RTC_DCHECK(sequence_checker_.CalledSequentially());
      48             : //     ... (do stuff) ...
      49             : //   }
      50             : //
      51             : //  private:
      52             : //   SequencedTaskChecker sequence_checker_;
      53             : // }
      54             : //
      55             : // In Release mode, CalledOnValidThread will always return true.
      56             : #if ENABLE_SEQUENCED_TASK_CHECKER
      57           0 : class LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerImpl {};
      58             : #else
      59             : class LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerDoNothing {};
      60             : #endif  // ENABLE_SEQUENCED_TASK_CHECKER_H_
      61             : 
      62             : namespace internal {
      63             : class SCOPED_LOCKABLE SequencedTaskCheckerScope {
      64             :  public:
      65             :   explicit SequencedTaskCheckerScope(const SequencedTaskChecker* checker)
      66             :       EXCLUSIVE_LOCK_FUNCTION(checker);
      67             :   ~SequencedTaskCheckerScope() UNLOCK_FUNCTION();
      68             : };
      69             : 
      70             : }  // namespace internal
      71             : 
      72             : #define RTC_DCHECK_CALLED_SEQUENTIALLY(x) \
      73             :   rtc::internal::SequencedTaskCheckerScope checker(x)
      74             : 
      75             : #undef ENABLE_SEQUENCED_TASK_CHECKER
      76             : 
      77             : }  // namespace rtc
      78             : #endif  // WEBRTC_BASE_SEQUENCED_TASK_CHECKER_H_

Generated by: LCOV version 1.13