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

Unified Diff: webrtc/base/thread_checker.h

Issue 2350663002: Change thread check to race check (Closed)
Patch Set: new impl Created 4 years, 3 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
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvoiceengine.cc » ('j') | webrtc/media/engine/webrtcvoiceengine.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/thread_checker.h
diff --git a/webrtc/base/thread_checker.h b/webrtc/base/thread_checker.h
index 3ae6e2c9f7f67514fddd3124bf3fc98b491c4226..2292dc5210547b67da8c03c53ed685f1cda13bb4 100644
--- a/webrtc/base/thread_checker.h
+++ b/webrtc/base/thread_checker.h
@@ -87,7 +87,14 @@ class LOCKABLE ThreadChecker : public ThreadCheckerDoNothing {
};
#endif // ENABLE_THREAD_CHECKER
-#undef ENABLE_THREAD_CHECKER
+// TODO(solenberg): Comment!
+#if ENABLE_THREAD_CHECKER
+class LOCKABLE NonReentrantChecker : public CriticalSection {
+};
+#else
+class LOCKABLE NonReentrantChecker {
+};
+#endif // ENABLE_THREAD_CHECKER
namespace internal {
class SCOPED_LOCKABLE AnnounceOnThread {
@@ -109,6 +116,17 @@ class SCOPED_LOCKABLE AnnounceOnThread {
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AnnounceOnThread);
};
+class SCOPED_LOCKABLE NonReentrantCheckerScope {
+ public:
+ explicit NonReentrantCheckerScope(const NonReentrantChecker& checker)
+ : try_lock_(&checker) {
+ RTC_DCHECK(try_lock_.locked());
+ }
+ ~NonReentrantCheckerScope() {}
+ private:
+ rtc::TryCritScope try_lock_;
+ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(NonReentrantCheckerScope);
+};
} // namespace internal
} // namespace rtc
@@ -184,4 +202,17 @@ class SCOPED_LOCKABLE AnnounceOnThread {
rtc::internal::AnnounceOnThread thread_announcer(thread_like_object); \
RTC_DCHECK(rtc::internal::AnnounceOnThread::IsCurrent(thread_like_object))
+// TODO(solenberg): COMMENT COMMENT COMMENT.
+#if ENABLE_THREAD_CHECKER
+#define __RTC_DCHECK_NON_REENTRANT_NAME(base, line) base ## line
+
+#define RTC_DCHECK_NON_REENTRANT(checker) \
+ rtc::internal::NonReentrantCheckerScope \
+ __RTC_DCHECK_NON_REENTRANT_NAME(checker, __LINE__)(checker);
kwiberg-webrtc 2016/09/20 10:55:21 The semicolon shouldn't be here.
+#else
+#define RTC_DCHECK_NON_REENTRANT(checker)
+#endif
+
+#undef ENABLE_THREAD_CHECKER
+
#endif // WEBRTC_BASE_THREAD_CHECKER_H_
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvoiceengine.cc » ('j') | webrtc/media/engine/webrtcvoiceengine.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698