The async server here uses one cq for both client and server:
https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc

- The idea here is to use an object (one per request) to maintain the
'state' of the request. In the above example, it is the 'CallData' . You
pass this as the *tag *to all operations.
- You start off your server by "requesting
<https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L91>"
a call by passing 'CallData' object as the tag.. In the example, the
CallData constructor does this and when the server starts off, it only
creates one CallData object
<https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L142>
(you
can create multiple CallData objects. Thats not a problem)
- Then the main processing loop just keeps calling cq->next
<https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L151>
and
since it knows the returned tag is of type 'CallData', it calls Proceed()
on it.
- Proceed
<https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L81>
is the one that maintains the request state machine (and note how CallData
passes itself as the tag
<https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L107>
for
other operations)..

Hope this helps,

thanks,
-Sree

On Fri, Nov 3, 2017 at 7:00 AM, <[email protected]> wrote:

> Hello,
>
> I have a "server" that behaves both as a server as well as a client, as
> the case may be. In both cases, asynchronous APIs are used. I have three
> threads:
> 1. The first thread listens on a "ServerCompletionQueue" using the Next()
> API.
> 2. The second thread behaves as a client and sends requests using a
> CompletionQueue object.
> 3. I also have a "response collection" thread that listens on the same 
> CompletionQueue
> object using the Next() API, to receive responses for requests that were
> made by the client thread.
>
> I was wondering if there is a way to tie both these completion queues
> together into a single completion queue. I would like to have a single
> completion queue object on which a. the server thread can listen, b. the
> client thread can send requests on, and c. the response collection thread
> can listen for responses on.
> If this is possible, how can I do this without having to use two different
> kinds of completion queue objects?
>
> Thanks!
>
> Regards,
> Akshitha
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/1961793d-9c69-4e7b-bda5-1786ddde8448%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/1961793d-9c69-4e7b-bda5-1786ddde8448%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CALRi9Qdt8Z0k24qgudd24_QvSZd0rFAR2WUfnjqUkZ0EveYsQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to