Merge "Prevent WaitForProperty() from using ~100% of CPU time on 32bit builds"

This commit is contained in:
Treehugger Robot 2018-02-14 20:33:24 +00:00 committed by Gerrit Code Review
commit 7c6b024241
1 changed files with 2 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include <algorithm>
#include <chrono>
#include <limits>
#include <string>
#include <android-base/parseint.h>
@ -109,7 +110,7 @@ static void WaitForPropertyCallback(void* data_ptr, const char*, const char* val
static void DurationToTimeSpec(timespec& ts, const std::chrono::milliseconds d) {
auto s = std::chrono::duration_cast<std::chrono::seconds>(d);
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(d - s);
ts.tv_sec = s.count();
ts.tv_sec = std::min<std::chrono::seconds::rep>(s.count(), std::numeric_limits<time_t>::max());
ts.tv_nsec = ns.count();
}