My code is as simple as below:

std::string serverAddr =
      qaic::qmonInetAll + ":" + std::to_string(config.port);

  GRPCService service;
  MonitorService::Service *monitorService = &service;
  ServiceExt::Service *monitorExtService = &service;

  service.init();

  ServerBuilder builder;
  builder.AddListeningPort(serverAddr, grpc::InsecureServerCredentials());
  
  notification_queue_ = builder.AddCompletionQueue();
  client_queue_ = builder.AddCompletionQueue();
  
  builder.RegisterService(monitorService);
  builder.RegisterService(monitorExtService);
  builder.RegisterService(&monitorAsyncService_);

  server_ = builder.BuildAndStart();
  LogInfoG("Server listening on {}", serverAddr);

  // Queue a connect wait request
  initClientSink();

  // start 2 threads for receiving messages.
  clientConnectThread_ =
      std::thread(&QMonitorTaskStarter::startClientConnectThread, this);
  notificationThread_ =
      std::thread(&QMonitorTaskStarter::startNotificationThread, this);
  if (asyncTestSupport) {
    type2MsgGenThread_ =
        std::thread(&QMonitorTaskStarter::genType2Messages, this);
  }

  readyStatus.set_value(QS_SUCCESS);

  server_->Wait();
  // Kill threads and wait for them to exit
  notification_queue_->Shutdown();
  client_queue_->Shutdown();
  // The threads should exit once a trycancel is called
  // on every client
  clientConnectThread_.join();
  notificationThread_.join();


Let me know if I code is correct.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/621ec42e-ff90-4050-b1d1-85983a475088o%40googlegroups.com.

Reply via email to