OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 private: | 89 private: |
90 RTC_DISALLOW_COPY_AND_ASSIGN(Runnable); | 90 RTC_DISALLOW_COPY_AND_ASSIGN(Runnable); |
91 }; | 91 }; |
92 | 92 |
93 // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). | 93 // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). |
94 | 94 |
95 class Thread : public MessageQueue { | 95 class Thread : public MessageQueue { |
96 public: | 96 public: |
97 // Create a new Thread and optionally assign it to the passed SocketServer. | 97 // Create a new Thread and optionally assign it to the passed SocketServer. |
98 // Subclasses that override Clear should pass false for init_queue and call | 98 Thread(); |
99 // DoInit() from their constructor to prevent races with the | 99 explicit Thread(SocketServer* ss); |
100 // MessageQueueManager already using the object while the vtable is still | 100 explicit Thread(std::unique_ptr<SocketServer> ss); |
101 // being created. | |
102 explicit Thread(SocketServer* ss = nullptr, bool init_queue = true); | |
103 | 101 |
104 // NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or | 102 // NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or |
105 // guarantee Stop() is explicitly called before the subclass is destroyed). | 103 // guarantee Stop() is explicitly called before the subclass is destroyed). |
106 // This is required to avoid a data race between the destructor modifying the | 104 // This is required to avoid a data race between the destructor modifying the |
107 // vtable, and the Thread::PreRun calling the virtual method Run(). | 105 // vtable, and the Thread::PreRun calling the virtual method Run(). |
108 ~Thread() override; | 106 ~Thread() override; |
109 | 107 |
| 108 static std::unique_ptr<Thread> CreateWithSocketServer(); |
| 109 static std::unique_ptr<Thread> Create(); |
110 static Thread* Current(); | 110 static Thread* Current(); |
111 | 111 |
112 // Used to catch performance regressions. Use this to disallow blocking calls | 112 // Used to catch performance regressions. Use this to disallow blocking calls |
113 // (Invoke) for a given scope. If a synchronous call is made while this is in | 113 // (Invoke) for a given scope. If a synchronous call is made while this is in |
114 // effect, an assert will be triggered. | 114 // effect, an assert will be triggered. |
115 // Note that this is a single threaded class. | 115 // Note that this is a single threaded class. |
116 class ScopedDisallowBlockingCalls { | 116 class ScopedDisallowBlockingCalls { |
117 public: | 117 public: |
118 ScopedDisallowBlockingCalls(); | 118 ScopedDisallowBlockingCalls(); |
119 ~ScopedDisallowBlockingCalls(); | 119 ~ScopedDisallowBlockingCalls(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 RTC_DISALLOW_COPY_AND_ASSIGN(Thread); | 285 RTC_DISALLOW_COPY_AND_ASSIGN(Thread); |
286 }; | 286 }; |
287 | 287 |
288 // AutoThread automatically installs itself at construction | 288 // AutoThread automatically installs itself at construction |
289 // uninstalls at destruction, if a Thread object is | 289 // uninstalls at destruction, if a Thread object is |
290 // _not already_ associated with the current OS thread. | 290 // _not already_ associated with the current OS thread. |
291 | 291 |
292 class AutoThread : public Thread { | 292 class AutoThread : public Thread { |
293 public: | 293 public: |
294 explicit AutoThread(SocketServer* ss = nullptr); | 294 AutoThread(); |
295 ~AutoThread() override; | 295 ~AutoThread() override; |
296 | 296 |
297 private: | 297 private: |
298 RTC_DISALLOW_COPY_AND_ASSIGN(AutoThread); | 298 RTC_DISALLOW_COPY_AND_ASSIGN(AutoThread); |
299 }; | 299 }; |
300 | 300 |
301 // Win32 extension for threads that need to use COM | 301 // Win32 extension for threads that need to use COM |
302 #if defined(WEBRTC_WIN) | 302 #if defined(WEBRTC_WIN) |
303 class ComThread : public Thread { | 303 class ComThread : public Thread { |
304 public: | 304 public: |
(...skipping 21 matching lines...) Expand all Loading... |
326 | 326 |
327 private: | 327 private: |
328 SocketServer* old_ss_; | 328 SocketServer* old_ss_; |
329 | 329 |
330 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketServerScope); | 330 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketServerScope); |
331 }; | 331 }; |
332 | 332 |
333 } // namespace rtc | 333 } // namespace rtc |
334 | 334 |
335 #endif // WEBRTC_BASE_THREAD_H_ | 335 #endif // WEBRTC_BASE_THREAD_H_ |
OLD | NEW |