summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fastos/src/vespa/fastos/thread.cpp9
-rw-r--r--fastos/src/vespa/fastos/thread.h15
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp7
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.h2
4 files changed, 14 insertions, 19 deletions
diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp
index 3df8fa584a7..3e2f2674d97 100644
--- a/fastos/src/vespa/fastos/thread.cpp
+++ b/fastos/src/vespa/fastos/thread.cpp
@@ -352,17 +352,12 @@ void FastOS_ThreadInterface::Join ()
// FastOS_Runnable
// ----------------------------------------------------------------------
-FastOS_Runnable::FastOS_Runnable(void)
+FastOS_Runnable::FastOS_Runnable()
: _thread(nullptr)
{
}
-FastOS_Runnable::~FastOS_Runnable(void)
+FastOS_Runnable::~FastOS_Runnable()
{
// assert(_thread == nullptr);
}
-
-void FastOS_Runnable::Detach(void)
-{
- _thread = nullptr;
-}
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index c025a48d563..12866c71b2c 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -148,7 +148,7 @@ public:
/**
* Destructor. Closes pool if necessary.
*/
- virtual ~FastOS_ThreadPool(void);
+ virtual ~FastOS_ThreadPool();
/**
@@ -168,9 +168,9 @@ public:
* Get the stack size used for threads in this pool.
* @return Stack size in bytes.
*/
- int GetStackSize(void) const { return _stackSize; }
+ int GetStackSize() const { return _stackSize; }
- int GetStackGuardSize(void) const { return 0; }
+ int GetStackGuardSize() const { return 0; }
/**
* Close the threadpool. This involves setting the break flag on
@@ -469,7 +469,7 @@ public:
*/
class FastOS_Runnable
{
-protected:
+private:
friend class FastOS_ThreadInterface;
FastOS_ThreadInterface *_thread;
@@ -498,10 +498,9 @@ public:
*/
virtual void Run(FastOS_ThreadInterface *thisThread, void *arguments)=0;
- FastOS_ThreadInterface *GetThread(void) { return _thread; }
- const FastOS_ThreadInterface *GetThread(void) const { return _thread; }
- bool HasThread(void) const { return _thread != nullptr; }
- void Detach(void);
+ FastOS_ThreadInterface *GetThread() { return _thread; }
+ const FastOS_ThreadInterface *GetThread() const { return _thread; }
+ bool HasThread() const { return _thread != nullptr; }
};
#include <vespa/fastos/unix_thread.h>
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();