| 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 |
| 11 #include "webrtc/base/thread.h" | 11 #include "webrtc/rtc_base/thread.h" |
| 12 | 12 |
| 13 #if defined(WEBRTC_WIN) | 13 #if defined(WEBRTC_WIN) |
| 14 #include <comdef.h> | 14 #include <comdef.h> |
| 15 #elif defined(WEBRTC_POSIX) | 15 #elif defined(WEBRTC_POSIX) |
| 16 #include <time.h> | 16 #include <time.h> |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 #include "webrtc/base/checks.h" | 19 #include "webrtc/rtc_base/checks.h" |
| 20 #include "webrtc/base/logging.h" | 20 #include "webrtc/rtc_base/logging.h" |
| 21 #include "webrtc/base/nullsocketserver.h" | 21 #include "webrtc/rtc_base/nullsocketserver.h" |
| 22 #include "webrtc/base/platform_thread.h" | 22 #include "webrtc/rtc_base/platform_thread.h" |
| 23 #include "webrtc/base/stringutils.h" | 23 #include "webrtc/rtc_base/stringutils.h" |
| 24 #include "webrtc/base/timeutils.h" | 24 #include "webrtc/rtc_base/timeutils.h" |
| 25 #include "webrtc/base/trace_event.h" | 25 #include "webrtc/rtc_base/trace_event.h" |
| 26 | 26 |
| 27 namespace rtc { | 27 namespace rtc { |
| 28 | 28 |
| 29 ThreadManager* ThreadManager::Instance() { | 29 ThreadManager* ThreadManager::Instance() { |
| 30 RTC_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ()); | 30 RTC_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ()); |
| 31 return &thread_manager; | 31 return &thread_manager; |
| 32 } | 32 } |
| 33 | 33 |
| 34 ThreadManager::~ThreadManager() { | 34 ThreadManager::~ThreadManager() { |
| 35 // By above RTC_DEFINE_STATIC_LOCAL. | 35 // By above RTC_DEFINE_STATIC_LOCAL. |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 continue; | 462 continue; |
| 463 } | 463 } |
| 464 ++iter; | 464 ++iter; |
| 465 } | 465 } |
| 466 | 466 |
| 467 MessageQueue::Clear(phandler, id, removed); | 467 MessageQueue::Clear(phandler, id, removed); |
| 468 } | 468 } |
| 469 | 469 |
| 470 #if !defined(WEBRTC_MAC) | 470 #if !defined(WEBRTC_MAC) |
| 471 // Note that these methods have a separate implementation for mac and ios | 471 // Note that these methods have a separate implementation for mac and ios |
| 472 // defined in webrtc/base/thread_darwin.mm. | 472 // defined in webrtc/rtc_base/thread_darwin.mm. |
| 473 bool Thread::ProcessMessages(int cmsLoop) { | 473 bool Thread::ProcessMessages(int cmsLoop) { |
| 474 // Using ProcessMessages with a custom clock for testing and a time greater | 474 // Using ProcessMessages with a custom clock for testing and a time greater |
| 475 // than 0 doesn't work, since it's not guaranteed to advance the custom | 475 // than 0 doesn't work, since it's not guaranteed to advance the custom |
| 476 // clock's time, and may get stuck in an infinite loop. | 476 // clock's time, and may get stuck in an infinite loop. |
| 477 RTC_DCHECK(GetClockForTesting() == nullptr || cmsLoop == 0 || | 477 RTC_DCHECK(GetClockForTesting() == nullptr || cmsLoop == 0 || |
| 478 cmsLoop == kForever); | 478 cmsLoop == kForever); |
| 479 int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); | 479 int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); |
| 480 int cmsNext = cmsLoop; | 480 int cmsNext = cmsLoop; |
| 481 | 481 |
| 482 while (true) { | 482 while (true) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 // P2PTransportChannelPingTest, relying on the message posted in | 549 // P2PTransportChannelPingTest, relying on the message posted in |
| 550 // cricket::Connection::Destroy. | 550 // cricket::Connection::Destroy. |
| 551 ProcessMessages(0); | 551 ProcessMessages(0); |
| 552 rtc::ThreadManager::Instance()->SetCurrentThread(old_thread_); | 552 rtc::ThreadManager::Instance()->SetCurrentThread(old_thread_); |
| 553 if (old_thread_) { | 553 if (old_thread_) { |
| 554 MessageQueueManager::Add(old_thread_); | 554 MessageQueueManager::Add(old_thread_); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 } // namespace rtc | 558 } // namespace rtc |
| OLD | NEW |