diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-08 18:56:55 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-08 18:56:55 +0000 |
commit | 32286c1b4f19b0db0e899155dd26af8cde8a6b5b (patch) | |
tree | 26d715ea60d2bcb77e10e05985125241c8ef70f0 /vbench | |
parent | 2e3515a187d0b3aae7ae1afd2708f011b9b8bf22 (diff) |
Use std::mutex
Diffstat (limited to 'vbench')
-rw-r--r-- | vbench/src/vbench/core/dispatcher.h | 3 | ||||
-rw-r--r-- | vbench/src/vbench/core/dispatcher.hpp | 10 |
2 files changed, 6 insertions, 7 deletions
diff --git a/vbench/src/vbench/core/dispatcher.h b/vbench/src/vbench/core/dispatcher.h index 03e036fe261..21db6c931a4 100644 --- a/vbench/src/vbench/core/dispatcher.h +++ b/vbench/src/vbench/core/dispatcher.h @@ -5,7 +5,6 @@ #include "handler.h" #include "provider.h" #include "closeable.h" -#include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/util/gate.h> #include <vector> @@ -31,7 +30,7 @@ private: }; Handler<T> &_fallback; - vespalib::Lock _lock; + mutable std::mutex _lock; std::vector<ThreadState*> _threads; bool _closed; diff --git a/vbench/src/vbench/core/dispatcher.hpp b/vbench/src/vbench/core/dispatcher.hpp index 9fd5c5dd527..9a985797967 100644 --- a/vbench/src/vbench/core/dispatcher.hpp +++ b/vbench/src/vbench/core/dispatcher.hpp @@ -14,7 +14,7 @@ Dispatcher<T>::Dispatcher(Handler<T> &fallback) } template <typename T> -Dispatcher<T>::~Dispatcher() {} +Dispatcher<T>::~Dispatcher() = default; template <typename T> bool @@ -25,7 +25,7 @@ Dispatcher<T>::waitForThreads(size_t threads, size_t pollCnt) const vespalib::Thread::sleep(20); } { - vespalib::LockGuard guard(_lock); + std::lock_guard guard(_lock); if (_threads.size() >= threads) { return true; } @@ -40,7 +40,7 @@ Dispatcher<T>::close() { std::vector<ThreadState*> threads; { - vespalib::LockGuard guard(_lock); + std::lock_guard guard(_lock); std::swap(_threads, threads); _closed = true; } @@ -53,7 +53,7 @@ template <typename T> void Dispatcher<T>::handle(std::unique_ptr<T> obj) { - vespalib::LockGuard guard(_lock); + std::unique_lock guard(_lock); if (!_threads.empty()) { ThreadState *state = _threads.back(); _threads.pop_back(); @@ -75,7 +75,7 @@ Dispatcher<T>::provide() { ThreadState state; { - vespalib::LockGuard guard(_lock); + std::unique_lock guard(_lock); if (!_closed) { _threads.push_back(&state); guard.unlock(); |