| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 *smsg.ready = true; | 485 *smsg.ready = true; |
| 486 smsg.thread->socketserver()->WakeUp(); | 486 smsg.thread->socketserver()->WakeUp(); |
| 487 continue; | 487 continue; |
| 488 } | 488 } |
| 489 ++iter; | 489 ++iter; |
| 490 } | 490 } |
| 491 | 491 |
| 492 MessageQueue::Clear(phandler, id, removed); | 492 MessageQueue::Clear(phandler, id, removed); |
| 493 } | 493 } |
| 494 | 494 |
| 495 bool Thread::ProcessMessages(int cmsLoop) { | 495 bool Thread::ProcessMessages(int cmsLoop, int messages_limit) { |
| 496 int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); | 496 int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); |
| 497 int cmsNext = cmsLoop; | 497 int cmsNext = cmsLoop; |
| 498 int messages_processed = 0; |
| 498 | 499 |
| 499 while (true) { | 500 while (true) { |
| 500 #if __has_feature(objc_arc) | 501 #if __has_feature(objc_arc) |
| 501 @autoreleasepool | 502 @autoreleasepool |
| 502 #elif defined(WEBRTC_MAC) | 503 #elif defined(WEBRTC_MAC) |
| 503 // see: http://developer.apple.com/library/mac/#documentation/Cocoa/Referenc
e/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html | 504 // see: http://developer.apple.com/library/mac/#documentation/Cocoa/Referenc
e/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html |
| 504 // Each thread is supposed to have an autorelease pool. Also for event loops | 505 // Each thread is supposed to have an autorelease pool. Also for event loops |
| 505 // like this, autorelease pool needs to be created and drained/released | 506 // like this, autorelease pool needs to be created and drained/released |
| 506 // for each cycle. | 507 // for each cycle. |
| 507 ScopedAutoreleasePool pool; | 508 ScopedAutoreleasePool pool; |
| 508 #endif | 509 #endif |
| 509 { | 510 { |
| 510 Message msg; | 511 Message msg; |
| 511 if (!Get(&msg, cmsNext)) | 512 if (!Get(&msg, cmsNext)) |
| 512 return !IsQuitting(); | 513 return !IsQuitting(); |
| 513 Dispatch(&msg); | 514 Dispatch(&msg); |
| 515 if (messages_limit > 0) { |
| 516 ++messages_processed; |
| 517 if (messages_processed > messages_limit) { |
| 518 return true; |
| 519 } |
| 520 } |
| 514 | 521 |
| 515 if (cmsLoop != kForever) { | 522 if (cmsLoop != kForever) { |
| 516 cmsNext = static_cast<int>(TimeUntil(msEnd)); | 523 cmsNext = static_cast<int>(TimeUntil(msEnd)); |
| 517 if (cmsNext < 0) | 524 if (cmsNext < 0) |
| 518 return true; | 525 return true; |
| 519 } | 526 } |
| 520 } | 527 } |
| 521 } | 528 } |
| 522 } | 529 } |
| 523 | 530 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 if (SUCCEEDED(hr)) { | 574 if (SUCCEEDED(hr)) { |
| 568 Thread::Run(); | 575 Thread::Run(); |
| 569 CoUninitialize(); | 576 CoUninitialize(); |
| 570 } else { | 577 } else { |
| 571 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr; | 578 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr; |
| 572 } | 579 } |
| 573 } | 580 } |
| 574 #endif | 581 #endif |
| 575 | 582 |
| 576 } // namespace rtc | 583 } // namespace rtc |
| OLD | NEW |