From a9e08303d7f61999c1a9a912c3427dfa96117cc5 Mon Sep 17 00:00:00 2001 From: vjpai Date: Fri, 31 Jul 2015 07:55:06 -0700 Subject: [PATCH] Remove lambda from client definition --- test/cpp/qps/client.h | 51 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 28cd32a1974..5096376d4e9 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -41,6 +41,8 @@ #include #include +#include +#include namespace grpc { @@ -187,29 +189,8 @@ class Client { class Thread { public: Thread(Client* client, size_t idx) - : done_(false), - new_(nullptr), - impl_([this, idx, client]() { - for (;;) { - // run the loop body - bool thread_still_ok = client->ThreadFunc(&histogram_, idx); - // lock, see if we're done - std::lock_guard g(mu_); - if (!thread_still_ok) { - gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); - done_ = true; - } - if (done_) { - return; - } - // check if we're marking, swap out the histogram if so - if (new_) { - new_->Swap(&histogram_); - new_ = nullptr; - cv_.notify_one(); - } - } - }) {} + : done_(false), new_(nullptr), client_(client), idx_(idx), + impl_(&Thread::ThreadFunc, this) {} ~Thread() { { @@ -233,6 +214,28 @@ class Client { Thread(const Thread&); Thread& operator=(const Thread&); + void ThreadFunc() { + for (;;) { + // run the loop body + bool thread_still_ok = client_->ThreadFunc(&histogram_, idx_); + // lock, see if we're done + std::lock_guard g(mu_); + if (!thread_still_ok) { + gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); + done_ = true; + } + if (done_) { + return; + } + // check if we're marking, swap out the histogram if so + if (new_) { + new_->Swap(&histogram_); + new_ = nullptr; + cv_.notify_one(); + } + } + } + TestService::Stub* stub_; ClientConfig config_; std::mutex mu_; @@ -240,6 +243,8 @@ class Client { bool done_; Histogram* new_; Histogram histogram_; + Client *client_; + size_t idx_; std::thread impl_; };