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

Side by Side Diff: webrtc/modules/utility/source/process_thread_impl.h

Issue 2729053002: Add location to RegisterModule (Closed)
Patch Set: Format BUILD.gn Created 3 years, 9 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_SOURCE_PROCESS_THREAD_IMPL_H_ 11 #ifndef WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
12 #define WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_ 12 #define WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 #include <queue> 16 #include <queue>
17 17
18 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
19 #include "webrtc/base/location.h"
19 #include "webrtc/base/platform_thread.h" 20 #include "webrtc/base/platform_thread.h"
20 #include "webrtc/base/thread_checker.h" 21 #include "webrtc/base/thread_checker.h"
21 #include "webrtc/modules/utility/include/process_thread.h" 22 #include "webrtc/modules/utility/include/process_thread.h"
22 #include "webrtc/system_wrappers/include/event_wrapper.h" 23 #include "webrtc/system_wrappers/include/event_wrapper.h"
23 #include "webrtc/typedefs.h" 24 #include "webrtc/typedefs.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
26 27
27 class ProcessThreadImpl : public ProcessThread { 28 class ProcessThreadImpl : public ProcessThread {
28 public: 29 public:
29 explicit ProcessThreadImpl(const char* thread_name); 30 explicit ProcessThreadImpl(const char* thread_name);
30 ~ProcessThreadImpl() override; 31 ~ProcessThreadImpl() override;
31 32
32 void Start() override; 33 void Start() override;
33 void Stop() override; 34 void Stop() override;
34 35
35 void WakeUp(Module* module) override; 36 void WakeUp(Module* module) override;
36 void PostTask(std::unique_ptr<rtc::QueuedTask> task) override; 37 void PostTask(std::unique_ptr<rtc::QueuedTask> task) override;
37 38
38 void RegisterModule(Module* module) override; 39 void RegisterModule(Module* module, const rtc::Location& from) override;
39 void DeRegisterModule(Module* module) override; 40 void DeRegisterModule(Module* module) override;
40 41
41 protected: 42 protected:
42 static bool Run(void* obj); 43 static bool Run(void* obj);
43 bool Process(); 44 bool Process();
44 45
45 private: 46 private:
46 struct ModuleCallback { 47 struct ModuleCallback {
47 ModuleCallback() : module(nullptr), next_callback(0) {} 48 ModuleCallback() = delete;
48 ModuleCallback(const ModuleCallback& cb) 49 ModuleCallback(ModuleCallback&& cb) = default;
49 : module(cb.module), next_callback(cb.next_callback) {} 50 ModuleCallback(const ModuleCallback& cb) = default;
50 ModuleCallback(Module* module) : module(module), next_callback(0) {} 51 ModuleCallback(Module* module, const rtc::Location& location)
52 : module(module), location(location) {}
51 bool operator==(const ModuleCallback& cb) const { 53 bool operator==(const ModuleCallback& cb) const {
52 return cb.module == module; 54 return cb.module == module;
53 } 55 }
54 56
55 Module* const module; 57 Module* const module;
56 int64_t next_callback; // Absolute timestamp. 58 int64_t next_callback = 0; // Absolute timestamp.
59 const rtc::Location location;
57 60
58 private: 61 private:
59 ModuleCallback& operator=(ModuleCallback&); 62 ModuleCallback& operator=(ModuleCallback&);
60 }; 63 };
61 64
62 typedef std::list<ModuleCallback> ModuleList; 65 typedef std::list<ModuleCallback> ModuleList;
63 66
64 // Warning: For some reason, if |lock_| comes immediately before |modules_| 67 // Warning: For some reason, if |lock_| comes immediately before |modules_|
65 // with the current class layout, we will start to have mysterious crashes 68 // with the current class layout, we will start to have mysterious crashes
66 // on Mac 10.9 debug. I (Tommi) suspect we're hitting some obscure alignemnt 69 // on Mac 10.9 debug. I (Tommi) suspect we're hitting some obscure alignemnt
67 // issues, but I haven't figured out what they are, if there are alignment 70 // issues, but I haven't figured out what they are, if there are alignment
68 // requirements for mutexes on Mac or if there's something else to it. 71 // requirements for mutexes on Mac or if there's something else to it.
69 // So be careful with changing the layout. 72 // So be careful with changing the layout.
70 rtc::CriticalSection lock_; // Used to guard modules_, tasks_ and stop_. 73 rtc::CriticalSection lock_; // Used to guard modules_, tasks_ and stop_.
71 74
72 rtc::ThreadChecker thread_checker_; 75 rtc::ThreadChecker thread_checker_;
73 const std::unique_ptr<EventWrapper> wake_up_; 76 const std::unique_ptr<EventWrapper> wake_up_;
74 // TODO(pbos): Remove unique_ptr and stop recreating the thread. 77 // TODO(pbos): Remove unique_ptr and stop recreating the thread.
75 std::unique_ptr<rtc::PlatformThread> thread_; 78 std::unique_ptr<rtc::PlatformThread> thread_;
76 79
77 ModuleList modules_; 80 ModuleList modules_;
78 std::queue<rtc::QueuedTask*> queue_; 81 std::queue<rtc::QueuedTask*> queue_;
79 bool stop_; 82 bool stop_;
80 const char* thread_name_; 83 const char* thread_name_;
81 }; 84 };
82 85
83 } // namespace webrtc 86 } // namespace webrtc
84 87
85 #endif // WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_ 88 #endif // WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/utility/include/process_thread.h ('k') | webrtc/modules/utility/source/process_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698