rtc::Event: Add TimeDelta support.
This CL adds TimeDelta support to the rtc::Event, and updates the Wait implementations to work with the improved precision. Bug: webrtc:14366 Change-Id: Iefeb638b18176a34f4ed2a5131754a7b7e6c9e99 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272002 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37831}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
6b3927d949
commit
1d5be49ff2
@ -11,6 +11,7 @@
|
||||
#include "rtc_base/event.h"
|
||||
|
||||
#include "rtc_base/platform_thread.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -65,6 +66,15 @@ class SignalerThread {
|
||||
PlatformThread thread_;
|
||||
};
|
||||
|
||||
TEST(EventTest, UnsignaledWaitDoesNotReturnBeforeTimeout) {
|
||||
constexpr webrtc::TimeDelta kDuration = webrtc::TimeDelta::Micros(10'499);
|
||||
Event event;
|
||||
auto begin = webrtc::Clock::GetRealTimeClock()->CurrentTime();
|
||||
EXPECT_FALSE(event.Wait(kDuration));
|
||||
EXPECT_GE(webrtc::Clock::GetRealTimeClock()->CurrentTime(),
|
||||
begin + kDuration);
|
||||
}
|
||||
|
||||
// These tests are disabled by default and only intended to be run manually.
|
||||
TEST(EventTest, DISABLED_PerformanceSingleThread) {
|
||||
static const int kNumIterations = 10000000;
|
||||
|
||||
Reference in New Issue
Block a user