| 352 | } |
| 353 | |
| 354 | void CallMethod(brpc::ChannelBase* channel, |
| 355 | brpc::Controller* cntl, |
| 356 | test::EchoRequest* req, test::EchoResponse* res, |
| 357 | bool async, bool destroy = false) { |
| 358 | google::protobuf::Closure* done = NULL; |
| 359 | brpc::CallId sync_id = { 0 }; |
| 360 | if (async) { |
| 361 | sync_id = cntl->call_id(); |
| 362 | done = brpc::DoNothing(); |
| 363 | } |
| 364 | ::test::EchoService::Stub(channel).Echo(cntl, req, res, done); |
| 365 | if (async) { |
| 366 | if (destroy) { |
| 367 | delete channel; |
| 368 | } |
| 369 | // Callback MUST be called for once and only once |
| 370 | bthread_id_join(sync_id); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | void CallMethod(brpc::ChannelBase* channel, |
| 375 | brpc::Controller* cntl, |
no test coverage detected