OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_ |
| 7 |
| 8 #include "mojo/public/cpp/system/macros.h" |
| 9 |
| 10 #if !defined(_WIN32) |
| 11 #include "mojo/public/cpp/bindings/lib/thread_checker_posix.h" |
| 12 #endif |
| 13 |
| 14 namespace mojo { |
| 15 namespace internal { |
| 16 |
| 17 class ThreadCheckerDoNothing { |
| 18 public: |
| 19 bool CalledOnValidThread() const MOJO_WARN_UNUSED_RESULT { |
| 20 return true; |
| 21 } |
| 22 }; |
| 23 |
| 24 // ThreadChecker is a class used to verify that some methods of a class are |
| 25 // called from the same thread. It is meant to be a member variable of a class. |
| 26 // The entire lifecycle of a ThreadChecker must occur on a single thread. |
| 27 // In Release mode (without dcheck_always_on), ThreadChecker does nothing. |
| 28 #if !defined(_WIN32) && (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 29 using ThreadChecker = ThreadCheckerPosix; |
| 30 #else |
| 31 using ThreadChecker = ThreadCheckerDoNothing; |
| 32 #endif |
| 33 |
| 34 } // namespace internal |
| 35 } // namespace mojo |
| 36 |
| 37 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_ |
OLD | NEW |