Index: webrtc/base/thread.cc |
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc |
index ed0c44674183e5c141a7638953446a89ec07b65a..3ce4628b366daed1f9454ea891274498c3a5437d 100644 |
--- a/webrtc/base/thread.cc |
+++ b/webrtc/base/thread.cc |
@@ -492,9 +492,10 @@ void Thread::Clear(MessageHandler* phandler, |
MessageQueue::Clear(phandler, id, removed); |
} |
-bool Thread::ProcessMessages(int cmsLoop) { |
+bool Thread::ProcessMessages(int cmsLoop, int messages_limit) { |
int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); |
int cmsNext = cmsLoop; |
+ int messages_processed = 0; |
while (true) { |
#if __has_feature(objc_arc) |
@@ -511,6 +512,12 @@ bool Thread::ProcessMessages(int cmsLoop) { |
if (!Get(&msg, cmsNext)) |
return !IsQuitting(); |
Dispatch(&msg); |
+ if (messages_limit > 0) { |
+ ++messages_processed; |
+ if (messages_processed > messages_limit) { |
+ return true; |
+ } |
+ } |
if (cmsLoop != kForever) { |
cmsNext = static_cast<int>(TimeUntil(msEnd)); |