From 49752dd142b687d74dcd00dfe1198d8933e74ee1 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 24 Nov 2017 10:49:28 +0000 Subject: Use standard locking in StorageBucketDBInitializer. --- .../src/vespa/storageframework/generic/thread/thread.cpp | 11 +++++++++++ .../src/vespa/storageframework/generic/thread/thread.h | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'storageframework') diff --git a/storageframework/src/vespa/storageframework/generic/thread/thread.cpp b/storageframework/src/vespa/storageframework/generic/thread/thread.cpp index 1a88b4d2044..5ed3f7dc5e6 100644 --- a/storageframework/src/vespa/storageframework/generic/thread/thread.cpp +++ b/storageframework/src/vespa/storageframework/generic/thread/thread.cpp @@ -17,5 +17,16 @@ Thread::interruptAndJoin(vespalib::Monitor* m) join(); } +void +Thread::interruptAndJoin(std::mutex &m, std::condition_variable &cv) +{ + interrupt(); + { + std::lock_guard guard(m); + cv.notify_all(); + } + join(); +} + } // framework } // storage diff --git a/storageframework/src/vespa/storageframework/generic/thread/thread.h b/storageframework/src/vespa/storageframework/generic/thread/thread.h index ceeba79ebe2..72054ff725a 100644 --- a/storageframework/src/vespa/storageframework/generic/thread/thread.h +++ b/storageframework/src/vespa/storageframework/generic/thread/thread.h @@ -14,6 +14,8 @@ #include "runnable.h" #include +#include +#include namespace vespalib { class Monitor; @@ -58,6 +60,8 @@ public: * through a monitor after the signalling face. */ void interruptAndJoin(vespalib::Monitor* m); + + void interruptAndJoin(std::mutex &m, std::condition_variable &cv); }; } -- cgit v1.2.3