Hi,

I have a question about the use of ServerAsyncResponseWriter objects.  If I 
have a thread that is running a completion queue, ie.:
// Completion queue thread does:
void Run() {
  for (;;) {
    void* tag = nullptr;
    bool ok = false;
    bool has_event = completion_queue_->Next(&tag, &ok);
    static_cast<CallData*>(tag)->Next(ok);
  }
}


class CallData {
 public:
  // similar to example code here:
  // 
https://github.com/grpc/grpc/blob/f2979e32185804ee707ab18da844d74496aeb479/examples/cpp/helloworld/greeter_async_server.cc#L99
  void Next(bool ok) {
    if (status_ == CREATE) {
    //...
    } else if (status_ == PROCESS) {
    // call initialization... create new request handler, etc..
    // 'The actual processing', ie. running the request, we would like
    // to pass this out to separate thread.  Something like:
    other_app_thread_->PostTask(handle_request_callback(request)); // 
non-blocking PostTask
    return;
  }
  //...
 private:
  ServerAsyncResponseWriter<HelloReply> responder_;
  // ...
};



    Can the |handle_request_callback| function invoke 
responder_.Finish(...) on another thread, while the completion queue is 
blocking at completion_queue_->Next(...) ?  If it is thread-safe, will it 
prompt the completion queue to complete the call (send the response), and 
appropriately invoke the CallData tag again when ready to enter the 
FINISHED state and delete this CallData object?

This question probably more generally applies to other async_unary_call.h 
classes.

Thanks!
Nick


-- 
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/1268b6d5-1d5b-411e-a4f6-787b9c741ecb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to