diff options
author | Konstantin Varlamov <var-const@users.noreply.github.com> | 2018-05-09 12:01:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-09 12:01:20 -0400 |
commit | 01ed7b20aec82163defd3e370e82ee9a83fbb951 (patch) | |
tree | 512c9be16a3536b63bea63e8307b31274cc745f8 /Firestore/core/src | |
parent | dbcd179788a4cce4e9e3ae545e736148438c5c6f (diff) |
Firestore C++: in AsyncQueue, use steady_clock instead of system_clock. (#1246)
This should prevent weird bugs due to system time readjustments. Because
operations are scheduled relative to now, the fact that the resulting
timepoint isn't in Unix epoch shouldn't matter.
Diffstat (limited to 'Firestore/core/src')
3 files changed, 4 insertions, 4 deletions
diff --git a/Firestore/core/src/firebase/firestore/util/executor_libdispatch.mm b/Firestore/core/src/firebase/firestore/util/executor_libdispatch.mm index b40f0dd..5491fec 100644 --- a/Firestore/core/src/firebase/firestore/util/executor_libdispatch.mm +++ b/Firestore/core/src/firebase/firestore/util/executor_libdispatch.mm @@ -109,7 +109,7 @@ class TimeSlot { void Execute(); void RemoveFromSchedule(); - using TimePoint = std::chrono::time_point<std::chrono::system_clock, + using TimePoint = std::chrono::time_point<std::chrono::steady_clock, Executor::Milliseconds>; ExecutorLibdispatch* const executor_; @@ -129,7 +129,7 @@ TimeSlot::TimeSlot(ExecutorLibdispatch* const executor, Executor::TaggedOperation&& operation) : executor_{executor}, target_time_{std::chrono::time_point_cast<Executor::Milliseconds>( - std::chrono::system_clock::now()) + + std::chrono::steady_clock::now()) + delay}, tagged_{std::move(operation)} { } diff --git a/Firestore/core/src/firebase/firestore/util/executor_std.cc b/Firestore/core/src/firebase/firestore/util/executor_std.cc index 59197e1..f03a712 100644 --- a/Firestore/core/src/firebase/firestore/util/executor_std.cc +++ b/Firestore/core/src/firebase/firestore/util/executor_std.cc @@ -68,7 +68,7 @@ DelayedOperation ExecutorStd::Schedule(const Milliseconds delay, "Schedule: delay cannot be negative"); namespace chr = std::chrono; - const auto now = chr::time_point_cast<Milliseconds>(chr::system_clock::now()); + const auto now = chr::time_point_cast<Milliseconds>(chr::steady_clock::now()); const auto id = PushOnSchedule(std::move(tagged.operation), now + delay, tagged.tag); diff --git a/Firestore/core/src/firebase/firestore/util/executor_std.h b/Firestore/core/src/firebase/firestore/util/executor_std.h index 4ac62e1..58ef96f 100644 --- a/Firestore/core/src/firebase/firestore/util/executor_std.h +++ b/Firestore/core/src/firebase/firestore/util/executor_std.h @@ -55,7 +55,7 @@ class Schedule { // - each operation modifying the queue notifies the condition variable `cv_`. public: using Duration = std::chrono::milliseconds; - using Clock = std::chrono::system_clock; + using Clock = std::chrono::steady_clock; // Entries are scheduled using absolute time. using TimePoint = std::chrono::time_point<Clock, Duration>; |