Configure threads with their own warning deadlines.

Design document:
https://docs.google.com/document/d/1c_Jk-eqoBl3mZcEW73OO_WOnWVO9nTU854DHcyqjQBo/edit?resourcekey=0-j2bRwX0nxCldQ_VjoPFAOQ#

Bug: webrtc:12405
Change-Id: Idab950a3293d7ca9328dfeb19ec6d3084f7e0e5f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203522
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33218}
This commit is contained in:
Harald Alvestrand
2021-01-27 21:52:14 +00:00
committed by Commit Bot
parent 9e1f08a88c
commit ba69442054
3 changed files with 33 additions and 4 deletions

View File

@ -290,6 +290,11 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
const std::string& name() const { return name_; }
bool SetName(const std::string& name, const void* obj);
// Sets the expected processing time in ms. The thread will write
// log messages when Invoke() takes more time than this.
// Default is 50 ms.
void SetDispatchWarningMs(int deadline);
// Starts the execution of the thread.
bool Start();
@ -525,6 +530,8 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
RecursiveCriticalSection* CritForTest() { return &crit_; }
private:
static const int kSlowDispatchLoggingThreshold = 50; // 50 ms
class QueuedTaskHandler final : public MessageHandler {
public:
QueuedTaskHandler() {}
@ -614,6 +621,8 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
friend class ThreadManager;
int dispatch_warning_ms_ RTC_GUARDED_BY(this) = kSlowDispatchLoggingThreshold;
RTC_DISALLOW_COPY_AND_ASSIGN(Thread);
};