diff options
author | 2015-08-18 12:44:57 -0700 | |
---|---|---|
committer | 2015-08-18 12:44:57 -0700 | |
commit | e50e5cbde2f77166b9f557938252de6792557f84 (patch) | |
tree | 9f98d7eeb39f1804eda3cbe996e0813f72a5c9f8 /include/grpc++ | |
parent | bb1c795f998f052f854a6e1aeebff44e293a29f4 (diff) |
Add a timeout to shutdown to forcefully end calls
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/server.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 8755b4b445..084c9936d5 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -63,7 +63,13 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { ~Server(); // Shutdown the server, block until all rpc processing finishes. - void Shutdown(); + // Forcefully terminate pending calls after deadline expires. + template <class T> + void Shutdown(const T& deadline) { + ShutdownInternal(TimePoint<T>(deadline).raw_time()); + } + + void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); } // Block waiting for all work to complete (the server must either // be shutting down or some other thread must call Shutdown for this @@ -98,6 +104,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE; + void ShutdownInternal(gpr_timespec deadline); + class BaseAsyncRequest : public CompletionQueueTag { public: BaseAsyncRequest(Server* server, ServerContext* context, |