summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2017-10-26 22:00:09 +0200
committerTor Egge <Tor.Egge@oath.com>2017-10-27 08:50:14 +0000
commit3dfebfe58bd6a730a732d9c1d9641d54647ea2f0 (patch)
tree85db42fcf69f6f185515452058c8f363a42cc624 /searchcore
parentc09a24a6496a81d3871ff5d78416092c6175b835 (diff)
Use std::mutex and std::condition_variable instead of FastOS_Cond.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.h17
2 files changed, 10 insertions, 10 deletions
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.cpp
index b4907627894..816bd69012a 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.cpp
@@ -117,7 +117,7 @@ FastS_DataSetBase::DeQueueHeadWakeup_HasLock()
queryQueued_t *queued;
queued = _queryQueue.GetFirst();
FastS_assert(queued->IsQueued());
- queued->LockCond();
+ auto queuedGuard(queued->getQueuedGuard());
//SetNowFromMonitor();
_queryQueue.DeQueueHead();
queued->UnmarkQueued();
@@ -127,7 +127,6 @@ FastS_DataSetBase::DeQueueHeadWakeup_HasLock()
} else {
queued->SignalCond();
}
- queued->UnlockCond();
}
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.h b/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.h
index a757d92fdeb..33dd8bda967 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/dataset_base.h
@@ -9,6 +9,7 @@
#include <vespa/fastos/time.h>
#include <vespa/fastos/cond.h>
#include <mutex>
+#include <condition_variable>
class FastS_TimeKeeper;
@@ -85,14 +86,16 @@ public:
queryQueued_t(const queryQueued_t &);
queryQueued_t& operator=(const queryQueued_t &);
- FastOS_Cond _queueCond;
+ std::mutex _queuedLock;
+ std::condition_variable _queuedCond;
queryQueued_t *_next;
bool _isAborted;
bool _isQueued;
FNET_Task *const _deQueuedTask;
public:
queryQueued_t(FNET_Task *const deQueuedTask)
- : _queueCond(),
+ : _queuedLock(),
+ _queuedCond(),
_next(NULL),
_isAborted(false),
_isQueued(false),
@@ -105,20 +108,18 @@ public:
FastS_assert(!_isQueued);
}
void Wait() {
- _queueCond.Lock();
+ std::unique_lock<std::mutex> queuedGuard(_queuedLock);
while (_isQueued) {
- _queueCond.Wait();
+ _queuedCond.wait(queuedGuard);
}
- _queueCond.Unlock();
}
bool IsAborted() const { return _isAborted; }
void MarkAbort() { _isAborted = true; }
void MarkQueued() { _isQueued = true; }
void UnmarkQueued() { _isQueued = false; }
bool IsQueued() const { return _isQueued; }
- void LockCond() { _queueCond.Lock(); }
- void UnlockCond() { _queueCond.Unlock(); }
- void SignalCond() { _queueCond.Signal(); }
+ std::unique_lock<std::mutex> getQueuedGuard() { return std::unique_lock<std::mutex>(_queuedLock); }
+ void SignalCond() { _queuedCond.notify_one(); }
FNET_Task *
getDequeuedTask() const