OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ | |
12 #define WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ | |
13 | |
14 #pragma message("WARNING: utility/interface is DEPRECATED; use utility/include") | |
15 | |
16 #include "webrtc/typedefs.h" | |
17 #include "webrtc/base/scoped_ptr.h" | |
18 | |
19 namespace webrtc { | |
20 class Module; | |
21 | |
22 class ProcessTask { | |
23 public: | |
24 ProcessTask() {} | |
25 virtual ~ProcessTask() {} | |
26 | |
27 virtual void Run() = 0; | |
28 }; | |
29 | |
30 class ProcessThread { | |
31 public: | |
32 virtual ~ProcessThread(); | |
33 | |
34 static rtc::scoped_ptr<ProcessThread> Create(const char* thread_name); | |
35 | |
36 // Starts the worker thread. Must be called from the construction thread. | |
37 virtual void Start() = 0; | |
38 | |
39 // Stops the worker thread. Must be called from the construction thread. | |
40 virtual void Stop() = 0; | |
41 | |
42 // Wakes the thread up to give a module a chance to do processing right | |
43 // away. This causes the worker thread to wake up and requery the specified | |
44 // module for when it should be called back. (Typically the module should | |
45 // return 0 from TimeUntilNextProcess on the worker thread at that point). | |
46 // Can be called on any thread. | |
47 virtual void WakeUp(Module* module) = 0; | |
48 | |
49 // Queues a task object to run on the worker thread. Ownership of the | |
50 // task object is transferred to the ProcessThread and the object will | |
51 // either be deleted after running on the worker thread, or on the | |
52 // construction thread of the ProcessThread instance, if the task did not | |
53 // get a chance to run (e.g. posting the task while shutting down or when | |
54 // the thread never runs). | |
55 virtual void PostTask(rtc::scoped_ptr<ProcessTask> task) = 0; | |
56 | |
57 // Adds a module that will start to receive callbacks on the worker thread. | |
58 // Can be called from any thread. | |
59 virtual void RegisterModule(Module* module) = 0; | |
60 | |
61 // Removes a previously registered module. | |
62 // Can be called from any thread. | |
63 virtual void DeRegisterModule(Module* module) = 0; | |
64 }; | |
65 | |
66 } // namespace webrtc | |
67 | |
68 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_ | |
OLD | NEW |