Delete ProcessThread creation from test TimeController as unused

Bug: webrtc:7219
Change-Id: Ia34f24a804b8a1e06b089774e37cac6e6d749e82
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266366
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37311}
This commit is contained in:
Danil Chapovalov
2022-06-21 11:38:32 +02:00
committed by WebRTC LUCI CQ
parent 4d3ba77975
commit 24b0543ee0
12 changed files with 1 additions and 409 deletions

View File

@ -19,110 +19,12 @@
#include "api/task_queue/task_queue_factory.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/include/module.h"
#include "modules/utility/include/process_thread.h"
#include "rtc_base/checks.h"
#include "rtc_base/synchronization/yield_policy.h"
#include "test/time_controller/simulated_time_controller.h"
namespace webrtc {
// Wraps a ProcessThread so that it can reschedule the time controller whenever
// an external call changes the ProcessThread's state. For example, when a new
// module is registered, the ProcessThread may need to be called sooner than the
// time controller's currently-scheduled deadline.
class ExternalTimeController::ProcessThreadWrapper : public ProcessThread {
public:
ProcessThreadWrapper(ExternalTimeController* parent,
std::unique_ptr<ProcessThread> thread)
: parent_(parent), thread_(std::move(thread)) {}
void Start() override {
parent_->UpdateTime();
thread_->Start();
parent_->ScheduleNext();
}
void Stop() override {
parent_->UpdateTime();
thread_->Stop();
parent_->ScheduleNext();
}
void WakeUp(Module* module) override {
parent_->UpdateTime();
thread_->WakeUp(GetWrapper(module));
parent_->ScheduleNext();
}
void PostTask(std::unique_ptr<QueuedTask> task) override {
parent_->UpdateTime();
thread_->PostTask(std::move(task));
parent_->ScheduleNext();
}
void PostDelayedTask(std::unique_ptr<QueuedTask> task,
uint32_t milliseconds) override {
parent_->UpdateTime();
thread_->PostDelayedTask(std::move(task), milliseconds);
parent_->ScheduleNext();
}
void RegisterModule(Module* module, const rtc::Location& from) override {
parent_->UpdateTime();
module_wrappers_.emplace(module, new ModuleWrapper(module, this));
thread_->RegisterModule(GetWrapper(module), from);
parent_->ScheduleNext();
}
void DeRegisterModule(Module* module) override {
parent_->UpdateTime();
thread_->DeRegisterModule(GetWrapper(module));
parent_->ScheduleNext();
module_wrappers_.erase(module);
}
private:
class ModuleWrapper : public Module {
public:
ModuleWrapper(Module* module, ProcessThreadWrapper* thread)
: module_(module), thread_(thread) {}
int64_t TimeUntilNextProcess() override {
return module_->TimeUntilNextProcess();
}
void Process() override { module_->Process(); }
void ProcessThreadAttached(ProcessThread* process_thread) override {
if (process_thread) {
module_->ProcessThreadAttached(thread_);
} else {
module_->ProcessThreadAttached(nullptr);
}
}
private:
Module* module_;
ProcessThreadWrapper* thread_;
};
void Delete() override {
// ProcessThread shouldn't be deleted as a TaskQueue.
RTC_DCHECK_NOTREACHED();
}
ModuleWrapper* GetWrapper(Module* module) {
auto it = module_wrappers_.find(module);
RTC_DCHECK(it != module_wrappers_.end());
return it->second.get();
}
ExternalTimeController* const parent_;
std::unique_ptr<ProcessThread> thread_;
std::map<Module*, std::unique_ptr<ModuleWrapper>> module_wrappers_;
};
// Wraps a TaskQueue so that it can reschedule the time controller whenever
// an external call schedules a new task.
class ExternalTimeController::TaskQueueWrapper : public TaskQueueBase {
@ -187,12 +89,6 @@ TaskQueueFactory* ExternalTimeController::GetTaskQueueFactory() {
return this;
}
std::unique_ptr<ProcessThread> ExternalTimeController::CreateProcessThread(
const char* thread_name) {
return std::make_unique<ProcessThreadWrapper>(
this, impl_.CreateProcessThread(thread_name));
}
void ExternalTimeController::AdvanceTime(TimeDelta duration) {
alarm_->Sleep(duration);
}