Skip to content

Commit

Permalink
Merge pull request grpc#6461 from y-zeng/fix-async-example
Browse files Browse the repository at this point in the history
Check the value of Next in async examples
  • Loading branch information
jtattermusch committed Jun 9, 2016
2 parents d36b901 + 2eedca7 commit 16816cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/cpp/helloworld/greeter_async_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion examples/cpp/helloworld/greeter_async_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 16816cd

Please sign in to comment.