Add check for IsCurrent() for SendTask in SingleThreadedTaskQueueForTesting.
The "IsCurrent" check seems to have been missing from the class, but may help with tracking down issue 10880. I also replaced the 'infinite' wait in SendTask with a couple of timeouts, arbitrarily chosen 30 seconds for 'abandon wait' and 10 seconds for 'warning' log. Change-Id: Ia40a68658dd007c60771135718511f7e4110c0b0 Bug: webrtc:10880 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149068 Commit-Queue: Tommi <tommi@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28865}
This commit is contained in:
parent
65feec5440
commit
6e4791fe49
@ -80,12 +80,14 @@ SingleThreadedTaskQueueForTesting::PostDelayedTask(Task task,
|
||||
}
|
||||
|
||||
void SingleThreadedTaskQueueForTesting::SendTask(Task task) {
|
||||
RTC_DCHECK(!IsCurrent());
|
||||
rtc::Event done;
|
||||
PostTask([&task, &done]() {
|
||||
task();
|
||||
done.Set();
|
||||
});
|
||||
done.Wait(rtc::Event::kForever);
|
||||
// Give up after 30 seconds, warn after 10.
|
||||
RTC_CHECK(done.Wait(30000, 10000));
|
||||
}
|
||||
|
||||
bool SingleThreadedTaskQueueForTesting::CancelTask(TaskId task_id) {
|
||||
@ -99,6 +101,10 @@ bool SingleThreadedTaskQueueForTesting::CancelTask(TaskId task_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SingleThreadedTaskQueueForTesting::IsCurrent() {
|
||||
return rtc::IsThreadRefEqual(thread_.GetThreadRef(), rtc::CurrentThreadRef());
|
||||
}
|
||||
|
||||
void SingleThreadedTaskQueueForTesting::Run(void* obj) {
|
||||
static_cast<SingleThreadedTaskQueueForTesting*>(obj)->RunLoop();
|
||||
}
|
||||
|
||||
@ -56,6 +56,9 @@ class SingleThreadedTaskQueueForTesting {
|
||||
// only for invalid task IDs, or for tasks which have already been executed.
|
||||
bool CancelTask(TaskId task_id);
|
||||
|
||||
// Returns true iff called on the thread associated with the task queue.
|
||||
bool IsCurrent();
|
||||
|
||||
private:
|
||||
struct QueuedTask {
|
||||
QueuedTask(TaskId task_id, int64_t earliest_execution_time, Task task);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user