Make ProcessThread be a TaskQueue implementation

That would allow to switch components from relying on ProcessThreads to
relying on TaskQueue one by one, without introducing new threads.

Bug: webrtc:6289
Change-Id: I18fe5d679d4d4d0ddf4a11900c9814eb570284d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167533
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30631}
This commit is contained in:
Danil Chapovalov
2020-02-27 13:37:43 +01:00
committed by Commit Bot
parent a7382f7879
commit 14273de88b
9 changed files with 139 additions and 32 deletions

View File

@ -14,6 +14,7 @@
#include <memory>
#include "api/task_queue/queued_task.h"
#include "api/task_queue/task_queue_base.h"
namespace rtc {
class Location;
@ -26,9 +27,9 @@ class Module;
// interface. There exists one override besides ProcessThreadImpl,
// MockProcessThread, but when looking at how it is used, it seems
// a nullptr might suffice (or simply an actual ProcessThread instance).
class ProcessThread {
class ProcessThread : public TaskQueueBase {
public:
virtual ~ProcessThread();
~ProcessThread() override;
static std::unique_ptr<ProcessThread> Create(const char* thread_name);
@ -45,14 +46,6 @@ class ProcessThread {
// Can be called on any thread.
virtual void WakeUp(Module* module) = 0;
// Queues a task object to run on the worker thread. Ownership of the
// task object is transferred to the ProcessThread and the object will
// either be deleted after running on the worker thread, or on the
// construction thread of the ProcessThread instance, if the task did not
// get a chance to run (e.g. posting the task while shutting down or when
// the thread never runs).
virtual void PostTask(std::unique_ptr<QueuedTask> task) = 0;
// Adds a module that will start to receive callbacks on the worker thread.
// Can be called from any thread.
virtual void RegisterModule(Module* module, const rtc::Location& from) = 0;