Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(944)

Side by Side Diff: webrtc/modules/utility/include/process_thread.h

Issue 2020783003: Revert of Change ProcessThread's task type to be the one from TaskQueue. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ 11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
12 #define WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ 12 #define WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
13 13
14 #include <memory> 14 #include <memory>
15 15
16 #include "webrtc/typedefs.h" 16 #include "webrtc/typedefs.h"
17 17
18 #if defined(WEBRTC_WIN)
19 // Due to a bug in the std::unique_ptr implementation that ships with MSVS,
20 // we need the full definition of QueuedTask, on Windows.
21 #include "webrtc/base/task_queue.h"
22 #else
23 namespace rtc {
24 class QueuedTask;
25 }
26 #endif
27
28 namespace webrtc { 18 namespace webrtc {
29 class Module; 19 class Module;
30 20
31 // TODO(tommi): ProcessThread probably doesn't need to be a virtual 21 class ProcessTask {
32 // interface. There exists one override besides ProcessThreadImpl, 22 public:
33 // MockProcessThread, but when looking at how it is used, it seems 23 ProcessTask() {}
34 // a nullptr might suffice (or simply an actual ProcessThread instance). 24 virtual ~ProcessTask() {}
25
26 virtual void Run() = 0;
27 };
28
35 class ProcessThread { 29 class ProcessThread {
36 public: 30 public:
37 virtual ~ProcessThread(); 31 virtual ~ProcessThread();
38 32
39 static std::unique_ptr<ProcessThread> Create(const char* thread_name); 33 static std::unique_ptr<ProcessThread> Create(const char* thread_name);
40 34
41 // Starts the worker thread. Must be called from the construction thread. 35 // Starts the worker thread. Must be called from the construction thread.
42 virtual void Start() = 0; 36 virtual void Start() = 0;
43 37
44 // Stops the worker thread. Must be called from the construction thread. 38 // Stops the worker thread. Must be called from the construction thread.
45 virtual void Stop() = 0; 39 virtual void Stop() = 0;
46 40
47 // Wakes the thread up to give a module a chance to do processing right 41 // Wakes the thread up to give a module a chance to do processing right
48 // away. This causes the worker thread to wake up and requery the specified 42 // away. This causes the worker thread to wake up and requery the specified
49 // module for when it should be called back. (Typically the module should 43 // module for when it should be called back. (Typically the module should
50 // return 0 from TimeUntilNextProcess on the worker thread at that point). 44 // return 0 from TimeUntilNextProcess on the worker thread at that point).
51 // Can be called on any thread. 45 // Can be called on any thread.
52 virtual void WakeUp(Module* module) = 0; 46 virtual void WakeUp(Module* module) = 0;
53 47
54 // Queues a task object to run on the worker thread. Ownership of the 48 // Queues a task object to run on the worker thread. Ownership of the
55 // task object is transferred to the ProcessThread and the object will 49 // task object is transferred to the ProcessThread and the object will
56 // either be deleted after running on the worker thread, or on the 50 // either be deleted after running on the worker thread, or on the
57 // construction thread of the ProcessThread instance, if the task did not 51 // construction thread of the ProcessThread instance, if the task did not
58 // get a chance to run (e.g. posting the task while shutting down or when 52 // get a chance to run (e.g. posting the task while shutting down or when
59 // the thread never runs). 53 // the thread never runs).
60 virtual void PostTask(std::unique_ptr<rtc::QueuedTask> task) = 0; 54 virtual void PostTask(std::unique_ptr<ProcessTask> task) = 0;
61 55
62 // Adds a module that will start to receive callbacks on the worker thread. 56 // Adds a module that will start to receive callbacks on the worker thread.
63 // Can be called from any thread. 57 // Can be called from any thread.
64 virtual void RegisterModule(Module* module) = 0; 58 virtual void RegisterModule(Module* module) = 0;
65 59
66 // Removes a previously registered module. 60 // Removes a previously registered module.
67 // Can be called from any thread. 61 // Can be called from any thread.
68 virtual void DeRegisterModule(Module* module) = 0; 62 virtual void DeRegisterModule(Module* module) = 0;
69 }; 63 };
70 64
71 } // namespace webrtc 65 } // namespace webrtc
72 66
73 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ 67 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
OLDNEW
« no previous file with comments | « webrtc/modules/utility/include/mock/mock_process_thread.h ('k') | webrtc/modules/utility/source/process_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698