Remove RtcEventLogImpl dependency on rtc::TaskQueue

same functionality can be achieved by using TaskQueueBase directly

Bug: webrtc:14169
Change-Id: Id7c27afdbf61b4cab3d006d9a7b690b915759cdb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/333440
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41476}
This commit is contained in:
Danil Chapovalov 2024-01-04 13:09:39 +01:00 committed by WebRTC LUCI CQ
parent 3c8c1afaea
commit dc64596510
3 changed files with 10 additions and 14 deletions

View File

@ -461,7 +461,6 @@ if (rtc_enable_protobuf) {
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rtc_event", "../rtc_base:rtc_event",
"../rtc_base:rtc_task_queue",
"../rtc_base:safe_conversions", "../rtc_base:safe_conversions",
"../rtc_base:safe_minmax", "../rtc_base:safe_minmax",
"../rtc_base:timeutils", "../rtc_base:timeutils",

View File

@ -56,10 +56,9 @@ RtcEventLogImpl::RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> encoder,
max_config_events_in_history_(max_config_events_in_history), max_config_events_in_history_(max_config_events_in_history),
event_encoder_(std::move(encoder)), event_encoder_(std::move(encoder)),
last_output_ms_(rtc::TimeMillis()), last_output_ms_(rtc::TimeMillis()),
task_queue_( task_queue_(task_queue_factory->CreateTaskQueue(
std::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue(
"rtc_event_log", "rtc_event_log",
TaskQueueFactory::Priority::NORMAL))) {} TaskQueueFactory::Priority::NORMAL)) {}
RtcEventLogImpl::~RtcEventLogImpl() { RtcEventLogImpl::~RtcEventLogImpl() {
// If we're logging to the output, this will stop that. Blocking function. // If we're logging to the output, this will stop that. Blocking function.
@ -72,10 +71,12 @@ RtcEventLogImpl::~RtcEventLogImpl() {
StopLogging(); StopLogging();
} }
// We want to block on any executing task by invoking ~TaskQueue() before // Since we are posting tasks bound to `this`, it is critical that the event
// log and its members outlive `task_queue_`. Destruct `task_queue_` first
// to ensure tasks living on the queue can access other members.
// We want to block on any executing task by deleting TaskQueue before
// we set unique_ptr's internal pointer to null. // we set unique_ptr's internal pointer to null.
rtc::TaskQueue* tq = task_queue_.get(); task_queue_.get_deleter()(task_queue_.get());
delete tq;
task_queue_.release(); task_queue_.release();
} }

View File

@ -23,10 +23,10 @@
#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtc_event_log_output.h" #include "api/rtc_event_log_output.h"
#include "api/sequence_checker.h" #include "api/sequence_checker.h"
#include "api/task_queue/task_queue_base.h"
#include "api/task_queue/task_queue_factory.h" #include "api/task_queue/task_queue_factory.h"
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h"
#include "rtc_base/system/no_unique_address.h" #include "rtc_base/system/no_unique_address.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
namespace webrtc { namespace webrtc {
@ -113,11 +113,7 @@ class RtcEventLogImpl final : public RtcEventLog {
bool immediately_output_mode_ RTC_GUARDED_BY(mutex_) = false; bool immediately_output_mode_ RTC_GUARDED_BY(mutex_) = false;
bool need_schedule_output_ RTC_GUARDED_BY(mutex_) = false; bool need_schedule_output_ RTC_GUARDED_BY(mutex_) = false;
// Since we are posting tasks bound to `this`, it is critical that the event std::unique_ptr<TaskQueueBase, TaskQueueDeleter> task_queue_;
// log and its members outlive `task_queue_`. Keep the `task_queue_`
// last to ensure it destructs first, or else tasks living on the queue might
// access other members after they've been torn down.
std::unique_ptr<rtc::TaskQueue> task_queue_;
Mutex mutex_; Mutex mutex_;
}; };