Drop support for link-time injection of the rtc::TaskQueue::Impl
Bug: webrtc:10191
Change-Id: I1b975e8a2230dd45828a4e7f4d5a86f61164445a
Reviewed-on: https://webrtc-review.googlesource.com/c/124121
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26870}
diff --git a/api/task_queue/task_queue_base.h b/api/task_queue/task_queue_base.h
index 175253b..b1b5cc7 100644
--- a/api/task_queue/task_queue_base.h
+++ b/api/task_queue/task_queue_base.h
@@ -13,7 +13,12 @@
#include <memory>
#include "api/task_queue/queued_task.h"
-#include "api/task_queue/task_queue_impl.h"
+
+// TODO(bugs.webrtc.org/10191): Remove when
+// rtc::TaskQueue* rtc::TaskQueue::Current() is unused.
+namespace rtc {
+class TaskQueue;
+} // namespace rtc
namespace webrtc {
@@ -21,10 +26,7 @@
// in FIFO order and that tasks never overlap. Tasks may always execute on the
// same worker thread and they may not. To DCHECK that tasks are executing on a
// known task queue, use IsCurrent().
-// TODO(bugs.webrtc.org/10191): Remove inheritence from rtc::TaskQueue::Impl
-// when all implementations switch to use TaskQueueFactory instead of link-time
-// injection.
-class TaskQueueBase : public rtc::TaskQueue::Impl {
+class TaskQueueBase {
public:
// Starts destruction of the task queue.
// On return ensures no task are running and no new tasks are able to start
@@ -35,7 +37,7 @@
// TaskQueue is deallocated and thus should not call any methods after Delete.
// Code running on the TaskQueue should not call Delete, but can assume
// TaskQueue still exists and may call other methods, e.g. PostTask.
- void Delete() override = 0;
+ virtual void Delete() = 0;
// Schedules a task to execute. Tasks are executed in FIFO order.
// If |task->Run()| returns true, task is deleted on the task queue
@@ -45,19 +47,17 @@
// TaskQueue or it may happen asynchronously after TaskQueue is deleted.
// This may vary from one implementation to the next so assumptions about
// lifetimes of pending tasks should not be made.
- void PostTask(std::unique_ptr<QueuedTask> task) override = 0;
+ virtual void PostTask(std::unique_ptr<QueuedTask> task) = 0;
// Schedules a task to execute a specified number of milliseconds from when
// the call is made. The precision should be considered as "best effort"
// and in some cases, such as on Windows when all high precision timers have
// been used up, can be off by as much as 15 millseconds.
- void PostDelayedTask(std::unique_ptr<QueuedTask> task,
- uint32_t milliseconds) override = 0;
+ virtual void PostDelayedTask(std::unique_ptr<QueuedTask> task,
+ uint32_t milliseconds) = 0;
- // Until all TaskQueue implementations switch to using CurrentTaskQueueSetter
- // below, this function may return nullptr even if code is executed by a
- // TaskQueue. Keep using rtc::TaskQueue::Current() until bugs.webrtc.org/10191
- // is resolved.
+ // Returns the task queue that is running the current thread.
+ // Returns nullptr if this thread is not associated with any task queue.
static TaskQueueBase* Current();
bool IsCurrent() const { return Current() == this; }
@@ -75,7 +75,11 @@
// Users of the TaskQueue should call Delete instead of directly deleting
// this object.
- ~TaskQueueBase() override = default;
+ virtual ~TaskQueueBase() = default;
+
+ private:
+ friend class rtc::TaskQueue;
+ rtc::TaskQueue* task_queue_ = nullptr;
};
struct TaskQueueDeleter {