diff --git a/api/sequence_checker.h b/api/sequence_checker.h index b9f466b9a7..a79d04f61f 100644 --- a/api/sequence_checker.h +++ b/api/sequence_checker.h @@ -107,9 +107,15 @@ class RTC_LOCKABLE SequenceChecker #define RTC_RUN_ON(x) \ RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x)) +// Checks current code is running on the desired sequence. +// +// First statement validates it is running on the sequence `x`. +// Second statement annotates for the thread safety analyzer the check was done. +// Such annotation has to be attached to a function, and that function has to be +// called. Thus current implementation creates a noop lambda and calls it. #define RTC_DCHECK_RUN_ON(x) \ RTC_DCHECK((x)->IsCurrent()) \ << webrtc::webrtc_sequence_checker_internal::ExpectationToString(x); \ - webrtc::webrtc_sequence_checker_internal::AssertHeld(x) + []() RTC_ASSERT_EXCLUSIVE_LOCK(x) {}() #endif // API_SEQUENCE_CHECKER_H_ diff --git a/rtc_base/synchronization/sequence_checker_internal.h b/rtc_base/synchronization/sequence_checker_internal.h index 3457765216..be89133a69 100644 --- a/rtc_base/synchronization/sequence_checker_internal.h +++ b/rtc_base/synchronization/sequence_checker_internal.h @@ -19,21 +19,9 @@ #include "rtc_base/system/rtc_export.h" #include "rtc_base/thread_annotations.h" -namespace rtc { -class TaskQueue; -} // namespace rtc - namespace webrtc { -class SequenceChecker; namespace webrtc_sequence_checker_internal { -inline void AssertHeld(const SequenceChecker* checker) - RTC_ASSERT_EXCLUSIVE_LOCK(checker) {} -inline void AssertHeld(const TaskQueueBase* task_queue) - RTC_ASSERT_EXCLUSIVE_LOCK(task_queue) {} -inline void AssertHeld(const rtc::TaskQueue* task_queue) - RTC_ASSERT_EXCLUSIVE_LOCK(task_queue) {} - // Real implementation of SequenceChecker, for use in debug mode, or // for temporary use in release mode (e.g. to RTC_CHECK on a threading issue // seen only in the wild).