In gRPC, we can use an async client to send multiple calls at the same time.
For example, with a service that has a RPC method Foo(), we need to call, in this order:
- First
auto reader = stub.AsyncFoo(&client_context, request, &completion_queue) - Then
reader->Finish(&response, &status, call_data) - Finally
completion_queue.Next()to get the status of the RPC.
My questions about thread safety are the following:
- Is it thread safe to call
Next()andAsyncFoo()at the same time in different threads? - Is it thread safe to call
Next()andFinish()at the same time in different threads? - Is it thread safe to call multiple
AsyncFoo()for different call data at the same time in different thread? - Is it thread safe to call multiple
Finish()for different call data at the same time in different thread? - For all the cases, if it is thread-safe: Is it thread-safe only when different threads are working with different stub or does it work also for the same stub?