How could I let server not get blocked when server->Wait() is called ?

30 views
Skip to first unread message

coin cheung

unread,
Mar 5, 2020, 2:34:30 AM3/5/20
to grpc.io
Hi,

Since my server function need to deal with a large amount of data, I hope that the server can work on dealing with these data when there is no client calls. Therefore,  when the client call arrives, the server can return the already dealt results to the client which will be much more efficient.

That means the server does work like this:
```cpp
//server.cpp
ServerBuilder builder; 
builder.AddListeningPort();
builder.RegisterService();
std::unique_ptr<grpc::Server> server(builder.BuildAndStart);
server->Wait(); // here the server blocks and wait for client calls. I need the server to execute the data dealing program when there is no client calls
```

I hope that when there is no client calls, the server can still execute some codo rather than get blocked and only wait for the client.

How could I do this please ?

Vijay Pai

unread,
Apr 22, 2020, 6:11:41 AM4/22/20
to grpc.io
Wait doesn't wait for client calls. It waits for shutdown of the server. The server starts processing calls as soon as you call BuildAndStart()
Reply all
Reply to author
Forward
0 new messages