Async APIs: CQ vs callbacks on client-side

49 views
Skip to first unread message

Илья Лукин

unread,
Oct 28, 2022, 3:47:12 AM10/28/22
to grpc.io
Hi,

I have tryed to prototype some examples with two types of async API, and I saw some differences. It's just for client-side.

1. When I use CQ:
I'm creating new thread to getting new tags from CQ in a loop (with AsyncNext). In main thread I'm calling methods which creates responders and runs async RPCs. So all of RPCs run asynchronously and I can see mixed output in my terminal.

2. When I use callbacks:
Each RPCs run asynchronously (with stub_->async()->), but whole programm is still synchronously and every next RPC should wait before previos will finish. So in my terminal I see consistently output.

For me, callbacks API looks much easier to understanding and I want to use it.
So, should I use something like std::future / std::async to get behaviour like CQ but with callbacks? Is it correct use case?
Reply all
Reply to author
Forward
0 new messages