aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/cpp
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-06-09 14:37:25 -0700
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-06-09 14:37:25 -0700
commit16816cdaeef0e7eeaa1860605a5f283215c29451 (patch)
treebbcc6eac9937acab67cfe35e0f116578f76c80b6 /examples/cpp
parentd36b9010d647c0610aa51c381773bf50d73d244f (diff)
parent2eedca72d53e9987da3a3a29961736312baf8b6f (diff)
Merge pull request #6461 from y-zeng/fix-async-example
Check the value of Next in async examples
Diffstat (limited to 'examples/cpp')
-rw-r--r--examples/cpp/helloworld/greeter_async_client.cc4
-rw-r--r--examples/cpp/helloworld/greeter_async_server.cc4
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc
index c1f5eb55f0..33de59fb95 100644
--- a/examples/cpp/helloworld/greeter_async_client.cc
+++ b/examples/cpp/helloworld/greeter_async_client.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.
diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc
index 64e065b1e4..ead44182e5 100644
--- a/examples/cpp/helloworld/greeter_async_server.cc
+++ b/examples/cpp/helloworld/greeter_async_server.cc
@@ -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();
}