Make RTC_LOG_THREAD_BLOCK_COUNT less spammy for known call counts
Also removing a count check from DestroyTransceiverChannel that's
not useful right now. We can bring it back when we have
DestroyChannelInterface better under control as far as Invokes goes.
Bug: none
Change-Id: I8e9c55a980f8f20e8b996fdc461fd90b0fbd4f3d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215201
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33730}
diff --git a/rtc_base/thread.h b/rtc_base/thread.h
index 6d3c39b..e031677f 100644
--- a/rtc_base/thread.h
+++ b/rtc_base/thread.h
@@ -61,8 +61,11 @@
// number of blocking thread calls.
// Note: Use of this macro, requires RTC_LOG_THREAD_BLOCK_COUNT() to be called
// first.
-#define RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x) \
- RTC_DCHECK_LE(blocked_call_count_printer.GetTotalBlockedCallCount(), x)
+#define RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x) \
+ do { \
+ blocked_call_count_printer.set_minimum_call_count_for_callback(x + 1); \
+ RTC_DCHECK_LE(blocked_call_count_printer.GetTotalBlockedCallCount(), x); \
+ } while (0)
#else
#define RTC_LOG_THREAD_BLOCK_COUNT()
#define RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x)
@@ -251,10 +254,19 @@
uint32_t GetCouldBeBlockingCallCount() const;
uint32_t GetTotalBlockedCallCount() const;
+ void set_minimum_call_count_for_callback(uint32_t minimum) {
+ min_blocking_calls_for_callback_ = minimum;
+ }
+
private:
Thread* const thread_;
const uint32_t base_blocking_call_count_;
const uint32_t base_could_be_blocking_call_count_;
+ // The minimum number of blocking calls required in order to issue the
+ // result_callback_. This is used by RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN to
+ // tame log spam.
+ // By default we always issue the callback, regardless of callback count.
+ uint32_t min_blocking_calls_for_callback_ = 0;
std::function<void(uint32_t, uint32_t)> result_callback_;
};