For what you're describing, is it sufficient to just do something like 
(assuming you're in a member function of a class that contains a Server 
pointer named server_)

std::thread t([this]{server_->Shutdown();});
... other stuff ...
t.join(); // when ready to finish work

That way you can initiate the Shutdown in a non-blocking fashion without 
waiting for its outcome. Keep in mind that Shutdown doesn't actually 
guarantee that no new work gets through, it just means that the application 
cannot expect to start new work and have it complete.

- Vijay

On Monday, May 21, 2018 at 9:50:48 AM UTC-7, Arpit Baldeva wrote:
>
> Hi,
>
> Previous discussion here - 
> https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/grpc-io/qOJaIoIzAu0/jdN9VYFLAAAJ
>  
>
> It seems like there is a discrepancy in the way grpc shutdown API works 
> between Java and C++. From Java docs, 
>
> shutdown()
> Initiates an orderly shutdown in which preexisting calls continue but new 
> calls are rejected.
>
> shutdownNow()
> Initiates a forceful shutdown in which preexisting and new calls are 
> rejected.
>
> The Java shutdown call looks non-blocking from the documentation. Looking 
> at C++ implementation, it looks like when the shutdown call is invoked 
> without specifying the deadline, it blocks until all the work is done. When 
> deadline is specified, the pending work will be cancelled after deadline. 
> The blocking nature of the Shutdown api makes it hard to initiate shutdown 
> sequence. Is it possible to add an api that simply stops new incoming work 
> in a non-blocking fashion (like Java shutdown API)? The application can 
> then process pending rpcs in a graceful manner and just block when 
> necessary. 
>
> Thanks. 
>

-- 
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/bd1f2d1f-6293-4912-91dd-df49f54b073d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to