Adds ability to tell Event::Wait to yield.
This will be used by simulated time controller to allow processing other
tasks while waiting on an Event. This makes posting of blocking tasks
possible.
Bug: webrtc:10365
Change-Id: Ic3fb156d545eed2c036939121b89295433176e26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128121
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27214}
diff --git a/rtc_base/event.cc b/rtc_base/event.cc
index 42c22a2..71dca49 100644
--- a/rtc_base/event.cc
+++ b/rtc_base/event.cc
@@ -21,6 +21,7 @@
#endif
#include "rtc_base/checks.h"
+#include "rtc_base/synchronization/yield_policy.h"
namespace rtc {
@@ -48,6 +49,7 @@
}
bool Event::Wait(int milliseconds) {
+ ScopedYieldPolicy::YieldExecution();
DWORD ms = (milliseconds == kForever) ? INFINITE : milliseconds;
return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0);
}
@@ -102,6 +104,8 @@
}
bool Event::Wait(int milliseconds) {
+ ScopedYieldPolicy::YieldExecution();
+
int error = 0;
struct timespec ts;