aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/performance
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2018-01-31 22:35:17 +0100
committerGravatar Jan Tattermusch <jtattermusch@google.com>2018-01-31 22:35:17 +0100
commit18f27376c531e857d8fb946d758c81880023ed42 (patch)
treee79ac5445c57a4c6bd36497435c4c236c46b9b41 /test/cpp/performance
parent382374eb6f373cb07b9b11371d6dda43138f0c26 (diff)
avoid touching stats_ instance field before base constructor
Diffstat (limited to 'test/cpp/performance')
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index 0866b58f58..86e3bbcd4e 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -142,25 +142,25 @@ class EndpointPairFixture {
class InProcessCHTTP2 : public EndpointPairFixture {
public:
- InProcessCHTTP2(Service* service)
- : EndpointPairFixture(service, MakeEndpoints()) {}
+ InProcessCHTTP2(Service* service, grpc_passthru_endpoint_stats* stats =
+ grpc_passthru_endpoint_stats_create())
+ : EndpointPairFixture(service, MakeEndpoints(stats)), stats_(stats) {}
- virtual ~InProcessCHTTP2() { grpc_passthru_endpoint_stats_destroy(stats_); }
+ virtual ~InProcessCHTTP2() {
+ if (stats_ != nullptr) {
+ grpc_passthru_endpoint_stats_destroy(stats_);
+ }
+ }
int writes_performed() const { return stats_->num_writes; }
private:
grpc_passthru_endpoint_stats* stats_;
- grpc_endpoint_pair MakeEndpoints() {
- stats_ = grpc_passthru_endpoint_stats_create(); // is there a better way to
- // initialize stats_ and
- // pass MakeEndpoints's
- // return value to base
- // constructor?
+ static grpc_endpoint_pair MakeEndpoints(grpc_passthru_endpoint_stats* stats) {
grpc_endpoint_pair p;
grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(),
- stats_);
+ stats);
return p;
}
};