aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-25 12:40:20 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-25 12:40:20 +0000
commit60a46e6bd697af9ffa4662dea221c901a7202e76 (patch)
treef4707df3eb83af3ceea8fb7a90b71b1959649814 /staging_vespalib
parent17968f6e8daa42a66720952e848b9080861bc358 (diff)
volatile -> std::atomic
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.h14
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();
};