Source release 17.1.2
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -53,6 +54,18 @@ void TestSleep::Sleep(unsigned int seconds) {
|
||||
if (callback_ != nullptr) callback_->ElapseTime(milliseconds);
|
||||
}
|
||||
|
||||
void TestSleep::SleepUntil(int64_t desired_time) {
|
||||
SyncFakeClock();
|
||||
const int64_t now = Clock().GetCurrentTime();
|
||||
if (desired_time < now) {
|
||||
LOGE("Test Clock skew sleeping from time %" PRId64 " to %" PRId64, now,
|
||||
desired_time);
|
||||
return;
|
||||
}
|
||||
const unsigned int sleep_time = static_cast<unsigned int>(desired_time - now);
|
||||
TestSleep::Sleep(sleep_time);
|
||||
}
|
||||
|
||||
void TestSleep::SyncFakeClock() {
|
||||
// Syncing can be done by sleeping 0 seconds.
|
||||
Sleep(0);
|
||||
|
||||
Reference in New Issue
Block a user