Skip to content
Snippets Groups Projects
Commit 2eedca72 authored by Yuchen Zeng's avatar Yuchen Zeng
Browse files

Check the value of Next() in async examples

parent 900ed587
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,9 @@ class GreeterClient { ...@@ -87,7 +87,9 @@ class GreeterClient {
void* got_tag; void* got_tag;
bool ok = false; bool ok = false;
// Block until the next result is available in the completion queue "cq". // 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 // Verify that the result from "cq" corresponds, by its tag, our previous
// request. // request.
......
...@@ -160,7 +160,9 @@ class ServerImpl final { ...@@ -160,7 +160,9 @@ class ServerImpl final {
// Block waiting to read the next event from the completion queue. The // 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 // event is uniquely identified by its tag, which in this case is the
// memory address of a CallData instance. // 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); GPR_ASSERT(ok);
static_cast<CallData*>(tag)->Proceed(); static_cast<CallData*>(tag)->Proceed();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment