我在我的程序中使用grpc::CompletionQueue
,您也可以在中找到示例
“grpc/examples/cpp/helloword/greeter_async_clients.cc
”。
问题代码如下!
// stub_->PrepareAsyncSayHello() creates an RPC object, returning
// an instance to store in "call" but does not actually start the RPC
// Because we are using the asynchronous API, we need to hold on to
// the "call" instance in order to get updates on the ongoing RPC.
call->response_reader =
stub_->PrepareAsyncSayHello(&call->context, request, &cq_);
// StartCall initiates the RPC call
call->response_reader->StartCall();
// Request that, upon completion of the RPC, "reply" be updated with the
// server's response; "status" with the indication of whether the operation
// was successful. Tag the request with the memory address of the call object.
call->response_reader->Finish(&call->reply, &call->status, (void*)call);
客户端向服务器发送1,2,3...100
,但服务器获取的号码列表为“100,99,98...2,1
”。为什么?我找不到任何关于此的源代码...非常感谢
并且是gRPC的Nagle算法吗?
答案 0 :(得分:0)
CompletionQueue
有点用词不当。他们将按照他们完成的顺序(而不是发布的顺序)返回事件。
gRPC C ++默认禁用Nagle算法。