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