diff options
author | Tor Egge <Tor.Egge@oath.com> | 2017-10-27 12:25:22 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2017-10-27 12:25:22 +0000 |
commit | bfac5e28b274bf613728549c5dd4b597bd29a167 (patch) | |
tree | 9c8d69395d95a8778b298a0dfbe498a25a2abd6e /fnet/src | |
parent | b8a1d4557d0856b4da30779ba3b75676655d691e (diff) |
Use std::mutex and std::condition_variable instead of FastOS_Cond
in fnet FRT_SingleReqWait.
Diffstat (limited to 'fnet/src')
-rw-r--r-- | fnet/src/vespa/fnet/frt/invoker.cpp | 19 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/frt/invoker.h | 6 |
2 files changed, 14 insertions, 11 deletions
diff --git a/fnet/src/vespa/fnet/frt/invoker.cpp b/fnet/src/vespa/fnet/frt/invoker.cpp index 0cb364935df..5afc355c68f 100644 --- a/fnet/src/vespa/fnet/frt/invoker.cpp +++ b/fnet/src/vespa/fnet/frt/invoker.cpp @@ -8,7 +8,8 @@ LOG_SETUP(".fnet.frt.invoker"); FRT_SingleReqWait::FRT_SingleReqWait() - : _cond(), + : _lock(), + _cond(), _done(false), _waiting(false) { } @@ -18,12 +19,12 @@ FRT_SingleReqWait::~FRT_SingleReqWait() {} void FRT_SingleReqWait::WaitReq() { - _cond.Lock(); + std::unique_lock<std::mutex> guard(_lock); _waiting = true; - while(!_done) - _cond.Wait(); + while(!_done) { + _cond.wait(guard); + } _waiting = false; - _cond.Unlock(); } @@ -31,11 +32,11 @@ void FRT_SingleReqWait::RequestDone(FRT_RPCRequest *req) { (void) req; - _cond.Lock(); + std::unique_lock<std::mutex> guard(_lock); _done = true; - if (_waiting) - _cond.Signal(); - _cond.Unlock(); + if (_waiting) { + _cond.notify_one(); + } } diff --git a/fnet/src/vespa/fnet/frt/invoker.h b/fnet/src/vespa/fnet/frt/invoker.h index 7716430f842..15d74017200 100644 --- a/fnet/src/vespa/fnet/frt/invoker.h +++ b/fnet/src/vespa/fnet/frt/invoker.h @@ -5,8 +5,9 @@ #include "rpcrequest.h" #include <vespa/fnet/task.h> #include <vespa/fnet/ipackethandler.h> -#include <vespa/fastos/cond.h> #include <vespa/fastos/thread.h> +#include <mutex> +#include <condition_variable> class FRT_Method; class FRT_Supervisor; @@ -29,7 +30,8 @@ public: class FRT_SingleReqWait : public FRT_IRequestWait { private: - FastOS_Cond _cond; + std::mutex _lock; + std::condition_variable _cond; bool _done; bool _waiting; |