From 641455176a1241dea6dda7071ba4162f41a0b5fc Mon Sep 17 00:00:00 2001 From: tommi Date: Sat, 28 May 2016 11:00:30 -0700 Subject: [PATCH] Revert of Change ProcessThread's task type to be the one from TaskQueue. (patchset #3 id:80001 of https://codereview.webrtc.org/2016043003/ ) Reason for revert: Downstream issues Original issue's description: > Change ProcessThread's task type to be the one from TaskQueue. > ProcessThread will eventually be replaced by TaskQueue, so this is the first little step. > > BUG= > R=magjed@webrtc.org > > Committed: https://crrev.com/400a276c8a0b299190ff17a81edd8780a26d63d3 > Cr-Commit-Position: refs/heads/master@{#12952} TBR=magjed@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG= Review-Url: https://codereview.webrtc.org/2020783003 Cr-Commit-Position: refs/heads/master@{#12953} --- webrtc/modules/utility/BUILD.gn | 1 - .../include/mock/mock_process_thread.h | 4 ++-- .../modules/utility/include/process_thread.h | 24 +++++++------------ .../utility/source/process_thread_impl.cc | 5 ++-- .../utility/source/process_thread_impl.h | 5 ++-- .../source/process_thread_impl_unittest.cc | 8 ++----- webrtc/modules/utility/utility.gypi | 1 - .../video_coding/jitter_buffer_unittest.cc | 2 +- 8 files changed, 19 insertions(+), 31 deletions(-) diff --git a/webrtc/modules/utility/BUILD.gn b/webrtc/modules/utility/BUILD.gn index 849ea0239c..6cd3dbbd8c 100644 --- a/webrtc/modules/utility/BUILD.gn +++ b/webrtc/modules/utility/BUILD.gn @@ -41,7 +41,6 @@ source_set("utility") { deps = [ "../..:webrtc_common", - "../../base:rtc_task_queue", "../../common_audio", "../../system_wrappers", "../audio_coding", diff --git a/webrtc/modules/utility/include/mock/mock_process_thread.h b/webrtc/modules/utility/include/mock/mock_process_thread.h index c6520bb20f..621fcee818 100644 --- a/webrtc/modules/utility/include/mock/mock_process_thread.h +++ b/webrtc/modules/utility/include/mock/mock_process_thread.h @@ -28,14 +28,14 @@ class MockProcessThread : public ProcessThread { MOCK_METHOD0(Start, void()); MOCK_METHOD0(Stop, void()); MOCK_METHOD1(WakeUp, void(Module* module)); - MOCK_METHOD1(PostTask, void(rtc::QueuedTask* task)); + MOCK_METHOD1(PostTask, void(ProcessTask* task)); MOCK_METHOD1(RegisterModule, void(Module* module)); MOCK_METHOD1(DeRegisterModule, void(Module* module)); // MOCK_METHOD1 gets confused with mocking this method, so we work around it // by overriding the method from the interface and forwarding the call to a // mocked, simpler method. - void PostTask(std::unique_ptr task) /*override*/ { + void PostTask(std::unique_ptr task) /* override */ { PostTask(task.get()); } }; diff --git a/webrtc/modules/utility/include/process_thread.h b/webrtc/modules/utility/include/process_thread.h index 8524a5188e..f6913ea316 100644 --- a/webrtc/modules/utility/include/process_thread.h +++ b/webrtc/modules/utility/include/process_thread.h @@ -15,23 +15,17 @@ #include "webrtc/typedefs.h" -#if defined(WEBRTC_WIN) -// Due to a bug in the std::unique_ptr implementation that ships with MSVS, -// we need the full definition of QueuedTask, on Windows. -#include "webrtc/base/task_queue.h" -#else -namespace rtc { -class QueuedTask; -} -#endif - namespace webrtc { class Module; -// TODO(tommi): ProcessThread probably doesn't need to be a virtual -// 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 ProcessTask { + public: + ProcessTask() {} + virtual ~ProcessTask() {} + + virtual void Run() = 0; +}; + class ProcessThread { public: virtual ~ProcessThread(); @@ -57,7 +51,7 @@ class ProcessThread { // 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 task) = 0; + virtual void PostTask(std::unique_ptr task) = 0; // Adds a module that will start to receive callbacks on the worker thread. // Can be called from any thread. diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc index 66534dedea..4e3606ca08 100644 --- a/webrtc/modules/utility/source/process_thread_impl.cc +++ b/webrtc/modules/utility/source/process_thread_impl.cc @@ -11,7 +11,6 @@ #include "webrtc/modules/utility/source/process_thread_impl.h" #include "webrtc/base/checks.h" -#include "webrtc/base/task_queue.h" #include "webrtc/base/timeutils.h" #include "webrtc/modules/include/module.h" #include "webrtc/system_wrappers/include/logging.h" @@ -120,7 +119,7 @@ void ProcessThreadImpl::WakeUp(Module* module) { wake_up_->Set(); } -void ProcessThreadImpl::PostTask(std::unique_ptr task) { +void ProcessThreadImpl::PostTask(std::unique_ptr task) { // Allowed to be called on any thread. { rtc::CritScope lock(&lock_); @@ -219,7 +218,7 @@ bool ProcessThreadImpl::Process() { } while (!queue_.empty()) { - rtc::QueuedTask* task = queue_.front(); + ProcessTask* task = queue_.front(); queue_.pop(); lock_.Leave(); task->Run(); diff --git a/webrtc/modules/utility/source/process_thread_impl.h b/webrtc/modules/utility/source/process_thread_impl.h index 510ab52daf..330aec946c 100644 --- a/webrtc/modules/utility/source/process_thread_impl.h +++ b/webrtc/modules/utility/source/process_thread_impl.h @@ -33,7 +33,7 @@ class ProcessThreadImpl : public ProcessThread { void Stop() override; void WakeUp(Module* module) override; - void PostTask(std::unique_ptr task) override; + void PostTask(std::unique_ptr task) override; void RegisterModule(Module* module) override; void DeRegisterModule(Module* module) override; @@ -75,7 +75,8 @@ class ProcessThreadImpl : public ProcessThread { std::unique_ptr thread_; ModuleList modules_; - std::queue queue_; + // TODO(tommi): Support delayed tasks. + std::queue queue_; bool stop_; const char* thread_name_; }; diff --git a/webrtc/modules/utility/source/process_thread_impl_unittest.cc b/webrtc/modules/utility/source/process_thread_impl_unittest.cc index 1fe3a417f8..5b31870ac4 100644 --- a/webrtc/modules/utility/source/process_thread_impl_unittest.cc +++ b/webrtc/modules/utility/source/process_thread_impl_unittest.cc @@ -13,7 +13,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/task_queue.h" #include "webrtc/base/timeutils.h" #include "webrtc/modules/include/module.h" #include "webrtc/modules/utility/source/process_thread_impl.h" @@ -34,13 +33,10 @@ class MockModule : public Module { MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); }; -class RaiseEventTask : public rtc::QueuedTask { +class RaiseEventTask : public ProcessTask { public: RaiseEventTask(EventWrapper* event) : event_(event) {} - bool Run() override { - event_->Set(); - return true; - } + void Run() override { event_->Set(); } private: EventWrapper* event_; diff --git a/webrtc/modules/utility/utility.gypi b/webrtc/modules/utility/utility.gypi index 6e11f1654d..e5b0a4d9c0 100644 --- a/webrtc/modules/utility/utility.gypi +++ b/webrtc/modules/utility/utility.gypi @@ -14,7 +14,6 @@ 'dependencies': [ 'audio_coding_module', 'media_file', - '<(webrtc_root)/base/base.gyp:rtc_task_queue', '<(webrtc_root)/common_audio/common_audio.gyp:common_audio', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', ], diff --git a/webrtc/modules/video_coding/jitter_buffer_unittest.cc b/webrtc/modules/video_coding/jitter_buffer_unittest.cc index 56e41169ab..9bdce7a0ac 100644 --- a/webrtc/modules/video_coding/jitter_buffer_unittest.cc +++ b/webrtc/modules/video_coding/jitter_buffer_unittest.cc @@ -195,7 +195,7 @@ class ProcessThreadMock : public ProcessThread { MOCK_METHOD1(WakeUp, void(Module* module)); MOCK_METHOD1(RegisterModule, void(Module* module)); MOCK_METHOD1(DeRegisterModule, void(Module* module)); - void PostTask(std::unique_ptr task) /*override*/ {} + void PostTask(std::unique_ptr task) {} }; class TestBasicJitterBuffer : public ::testing::TestWithParam,