Check the value of Next() in async examples

pull/6461/head
Yuchen Zeng 9 years ago
parent 900ed58732
commit 2eedca72d5
  1. 4
      examples/cpp/helloworld/greeter_async_client.cc
  2. 4
      examples/cpp/helloworld/greeter_async_server.cc

@ -87,7 +87,9 @@ class GreeterClient {
void* got_tag;
bool ok = false;
// Block until the next result is available in the completion queue "cq".
cq.Next(&got_tag, &ok);
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or the cq_ is shutting down.
GPR_ASSERT(cq.Next(&got_tag, &ok));
// Verify that the result from "cq" corresponds, by its tag, our previous
// request.

@ -160,7 +160,9 @@ class ServerImpl final {
// Block waiting to read the next event from the completion queue. The
// event is uniquely identified by its tag, which in this case is the
// memory address of a CallData instance.
cq_->Next(&tag, &ok);
// The return value of Next should always be checked. This return value
// tells us whether there is any kind of event or cq_ is shutting down.
GPR_ASSERT(cq_->Next(&tag, &ok));
GPR_ASSERT(ok);
static_cast<CallData*>(tag)->Proceed();
}

Loading…
Cancel
Save