diff options
Diffstat (limited to 'storageframework')
-rw-r--r-- | storageframework/src/vespa/storageframework/generic/thread/thread.cpp | 11 | ||||
-rw-r--r-- | storageframework/src/vespa/storageframework/generic/thread/thread.h | 4 |
2 files changed, 15 insertions, 0 deletions
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<std::mutex> 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 <vespa/vespalib/stllike/string.h> +#include <mutex> +#include <condition_variable> 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); }; } |