Source release 19.4.0

This commit is contained in:
Vicky Min
2024-11-27 00:07:23 +00:00
parent 11c108a8da
commit 22759672a8
72 changed files with 5321 additions and 2622 deletions

View File

@@ -26,7 +26,7 @@
namespace wvutil {
bool TestSleep::real_sleep_ = true;
TestSleep::CallBack* TestSleep::callback_ = nullptr;
std::unordered_set<TestSleep::CallBack*> TestSleep::callbacks_;
int TestSleep::total_clock_rollback_seconds_ = 0;
void TestSleep::Sleep(unsigned int seconds) {
@@ -52,7 +52,7 @@ void TestSleep::Sleep(unsigned int seconds) {
milliseconds = total_real - fake_clock;
fake_clock += milliseconds;
}
if (callback_ != nullptr) callback_->ElapseTime(milliseconds);
for (auto* cb : callbacks_) cb->ElapseTime(milliseconds);
}
void TestSleep::SleepUntil(int64_t desired_time) {
@@ -80,9 +80,8 @@ void TestSleep::SetFakeClock(int64_t time_seconds) {
// by the current time on a real clock, and then the command line
// re-initializes it to 0, then delta is negative.
int64_t delta = time_seconds - Clock().GetCurrentTime();
if (callback_ != nullptr) {
callback_->ElapseTime(delta * 1000);
} else {
for (auto* cb : callbacks_) cb->ElapseTime(delta * 1000);
if (callbacks_.empty()) {
LOGE("Setting fake clock with no callback. This won't work.");
}
}
@@ -130,8 +129,8 @@ bool TestSleep::RollbackSystemTime(int seconds) {
// For both real and fake sleep we still update the callback and we still keep
// track of the total amount of time slept.
total_clock_rollback_seconds_ += seconds;
if (callback_ != nullptr) {
callback_->ElapseTime(-1000 * static_cast<int64_t>(seconds));
for (auto* cb : callbacks_) {
cb->ElapseTime(-1000 * static_cast<int64_t>(seconds));
}
return true;
}