aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-04 17:52:12 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-04 17:52:12 +0000
commit437d93bdab427e99e024ad4c0d57c305d6f68f47 (patch)
tree4e084738dedc44ce37eb9c224a8c59963c2c6d8d /staging_vespalib
parent3abd363e0bf07f0467fb9f66815833330f68b223 (diff)
Ensure that we have stopped the thread.
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp7
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.h2
2 files changed, 5 insertions, 4 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
index 0c7a9fe59ed..cd2a13029ab 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
@@ -41,9 +41,8 @@ Updater::Updater(Clock & clock, double timePeriod)
Updater::~Updater() = default;
void
-Updater::Run(FastOS_ThreadInterface *thread, void *arguments)
+Updater::Run(FastOS_ThreadInterface *thread, void *)
{
- (void) arguments;
_clock._running = true;
std::unique_lock<std::mutex> guard(_lock);
while ( ! thread->GetBreakFlag() && !_stop) {
@@ -73,7 +72,9 @@ Clock::Clock(double timePeriod) :
Clock::~Clock()
{
- _updater.reset();
+ if (_running) {
+ _updater->GetThread()->Join();
+ }
assert(!_running);
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h
index 61352cb6cdc..e9e1ebace3f 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.h
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.h
@@ -22,7 +22,7 @@ class Clock
private:
mutable std::atomic<int64_t> _timeNS;
std::unique_ptr<clock::internal::Updater> _updater;
- bool _running;
+ std::atomic<bool> _running;
void setTime() const;
void start();