aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2015-07-31 07:55:06 -0700
committerGravatar vjpai <vpai@google.com>2015-07-31 07:55:06 -0700
commita9e08303d7f61999c1a9a912c3427dfa96117cc5 (patch)
tree34ab30d468573465178d2e3b344532a292420f7c /test
parent51b48176ca40796229ca193371a7354dac097e22 (diff)
Remove lambda from client definition
Diffstat (limited to 'test')
-rw-r--r--test/cpp/qps/client.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 28cd32a197..5096376d4e 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -41,6 +41,8 @@
#include <condition_variable>
#include <mutex>
+#include <grpc++/config.h>
+#include <grpc++/config.h>
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<std::mutex> 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<std::mutex> 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_;
};