diff options
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/clock.cpp | 2 | ||||
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/clock.h | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp index 68929d0377c..5ae9d8cfb45 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp @@ -25,7 +25,7 @@ Clock::~Clock() void Clock::setTime() const { - _timeNS = (fastos::ClockSteady::now() - fastos::SteadyTimeStamp::ZERO); + _timeNS.store(fastos::ClockSteady::now() - fastos::SteadyTimeStamp::ZERO); } void Clock::Run(FastOS_ThreadInterface *thread, void *arguments) diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h index 7b0633a2b4f..fc8e9eaff23 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.h +++ b/staging_vespalib/src/vespa/vespalib/util/clock.h @@ -20,12 +20,12 @@ private: Clock(const Clock &); Clock & operator = (const Clock &); - mutable volatile int64_t _timeNS; - int _timePeriodMS; - std::mutex _lock; - std::condition_variable _cond; - bool _stop; - bool _running; + mutable std::atomic<int64_t> _timeNS; + int _timePeriodMS; + std::mutex _lock; + std::condition_variable _cond; + bool _stop; + bool _running; void setTime() const; @@ -41,7 +41,7 @@ public: } return getTimeNSAssumeRunning(); } - fastos::SteadyTimeStamp getTimeNSAssumeRunning() const { return fastos::SteadyTimeStamp(_timeNS); } + fastos::SteadyTimeStamp getTimeNSAssumeRunning() const { return fastos::SteadyTimeStamp(_timeNS.load(std::memory_order_relaxed)); } void stop(); }; |