diff options
author | vjpai <vpai@google.com> | 2015-05-04 16:39:18 -0700 |
---|---|---|
committer | vjpai <vpai@google.com> | 2015-05-04 16:39:18 -0700 |
commit | 0a4129399aa765dffdbbff81641939e6083fc373 (patch) | |
tree | ff69d9a40669273fbc9d681699640d6ae118117a | |
parent | 36ff3f00e2c05d16338cd251d3f90a90fcaf4597 (diff) |
Also need to create a vector of streams
-rw-r--r-- | test/cpp/qps/client_sync.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 565b8dcc0b..264293561d 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -99,25 +99,27 @@ class SynchronousUnaryClient GRPC_FINAL : public SynchronousClient { class SynchronousStreamingClient GRPC_FINAL : public SynchronousClient { public: SynchronousStreamingClient(const ClientConfig& config) - : SynchronousClient(config), context_(num_threads_) { + : SynchronousClient(config), context_(num_threads_), stream_(num_threads_) { for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) { auto* stub = channels_[thread_idx % channels_.size()].get_stub(); - stream_ = stub->StreamingCall(&context_[thread_idx]); + stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]); } StartThreads(num_threads_); } ~SynchronousStreamingClient() { EndThreads(); - if (stream_) { - SimpleResponse response; - stream_->WritesDone(); - EXPECT_TRUE(stream_->Finish().IsOk()); + for (auto stream = stream_.begin(); stream != stream_.end(); stream++) { + if (*stream) { + (*stream)->WritesDone(); + EXPECT_TRUE((*stream)->Finish().IsOk()); + } } } bool ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE { double start = Timer::Now(); - if (stream_->Write(request_) && stream_->Read(&responses_[thread_idx])) { + if (stream_[thread_idx]->Write(request_) && + stream_[thread_idx]->Read(&responses_[thread_idx])) { histogram->Add((Timer::Now() - start) * 1e9); return true; } @@ -126,8 +128,8 @@ class SynchronousStreamingClient GRPC_FINAL : public SynchronousClient { private: std::vector<grpc::ClientContext> context_; - std::unique_ptr<grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>> - stream_; + std::vector<std::unique_ptr<grpc::ClientReaderWriter< + SimpleRequest, SimpleResponse>>> stream_; }; std::unique_ptr<Client> CreateSynchronousUnaryClient( |