summaryrefslogtreecommitdiffstats
path: root/searchcore/src
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2017-10-26 22:18:07 +0200
committerTor Egge <Tor.Egge@oath.com>2017-10-27 08:50:15 +0000
commitd88277c9d965e5d47e9159f12cca3d766bb91e96 (patch)
tree16d05d81e571649786964aa29fa8587b29474145 /searchcore/src
parent3dfebfe58bd6a730a732d9c1d9641d54647ea2f0 (diff)
Use std::mutex and std::condition_variable instead of FastOS_Cond.
Diffstat (limited to 'searchcore/src')
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/common/search.cpp32
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/common/search.h10
2 files changed, 20 insertions, 22 deletions
diff --git a/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp b/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp
index e3c2e79fd1a..7685ddcc328 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/common/search.cpp
@@ -165,11 +165,11 @@ void
FastS_SyncSearchAdapter::DoneQuery(FastS_ISearch *,
FastS_SearchContext)
{
- Lock();
+ std::unique_lock<std::mutex> guard(_lock);
_queryDone = true;
- if (_waitQuery)
- Signal();
- Unlock();
+ if (_waitQuery) {
+ _cond.notify_one();
+ }
}
@@ -177,33 +177,33 @@ void
FastS_SyncSearchAdapter::DoneDocsums(FastS_ISearch *,
FastS_SearchContext)
{
- Lock();
+ std::unique_lock<std::mutex> guard(_lock);
_docsumsDone = true;
- if (_waitDocsums)
- Signal();
- Unlock();
+ if (_waitDocsums) {
+ _cond.notify_one();
+ }
}
void
FastS_SyncSearchAdapter::WaitQueryDone()
{
- Lock();
+ std::unique_lock<std::mutex> guard(_lock);
_waitQuery = true;
- while (!_queryDone)
- Wait();
- Unlock();
+ while (!_queryDone) {
+ _cond.wait(guard);
+ }
}
void
FastS_SyncSearchAdapter::WaitDocsumsDone()
{
- Lock();
+ std::unique_lock<std::mutex> guard(_lock);
_waitDocsums = true;
- while (!_docsumsDone)
- Wait();
- Unlock();
+ while (!_docsumsDone) {
+ _cond.wait(guard);
+ }
}
diff --git a/searchcore/src/vespa/searchcore/fdispatch/common/search.h b/searchcore/src/vespa/searchcore/fdispatch/common/search.h
index a6f22efd8cd..eb9a9bf3244 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/common/search.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/common/search.h
@@ -10,6 +10,8 @@
#include <vespa/document/base/globalid.h>
#include <vespa/fastos/cond.h>
#include <limits>
+#include <mutex>
+#include <condition_variable>
class FastS_ISearch;
@@ -469,7 +471,8 @@ class FastS_SyncSearchAdapter : public FastS_SearchAdapter,
public FastS_ISearchOwner
{
private:
- FastOS_Cond _cond;
+ std::mutex _lock;
+ std::condition_variable _cond;
bool _waitQuery;
bool _queryDone;
bool _waitDocsums;
@@ -483,11 +486,6 @@ public:
static FastS_ISearch *Adapt(FastS_ISearch *search);
- void Lock() { _cond.Lock(); }
- void Unlock() { _cond.Unlock(); }
- void Wait() { _cond.Wait(); }
- void Signal() { _cond.Signal(); }
-
virtual void DoneQuery(FastS_ISearch *, FastS_SearchContext) override;
virtual void DoneDocsums(FastS_ISearch *, FastS_SearchContext) override;