def stop
      # if called via run_till_terminated_or_interrupted,
      #   signal stop_server_thread and dont do anything
      if @stop_server.nil? == false && @stop_server == false
        @stop_server = true
        @stop_server_cv.broadcast
        return
      end
      @run_mutex.synchronize do
        fail 'Cannot stop before starting' if @running_state == :not_started
        return if @running_state != :running
        transition_running_state(:stopping)
        deadline = from_relative_time(@poll_period)
        @server.shutdown_and_notify(deadline)
      end
      @pool.stop
    end
def stop
      # if called via run_till_terminated_or_interrupted,
      #   signal stop_server_thread and dont do anything
      if @stop_server.nil? == false && @stop_server == false
        @stop_server = true
        @stop_server_cv.broadcast
        return
      end
      @run_mutex.synchronize do
        fail 'Cannot stop before starting' if @running_state == :not_started
        return if @running_state != :running
        transition_running_state(:stopping)
        deadline = from_relative_time(@poll_period)
        @server.shutdown_and_notify(deadline)
      end
      @pool.stop
    end
Creates a new RpcServer.

 The RPC server is configured using keyword arguments.

 There are some specific keyword args used to configure the RpcServer
 instance.

 * pool_size: the size of the thread pool the server uses to run its
 threads. No more concurrent requests can be made than the size
 of the thread pool

 * max_waiting_requests: Deprecated due to internal changes to the thread
 pool. This is still an argument for compatibility but is ignored.

 * poll_period: The amount of time in seconds to wait for
 currently-serviced RPC's to finish before cancelling them when shutting
 down the server.

 * pool_keep_alive: The amount of time in seconds to wait
 for currently busy thread-pool threads to finish before
 forcing an abrupt exit to each thread.

 * connect_md_proc:
 when non-nil is a proc for determining metadata to send back the client
 on receiving an invocation req.  The proc signature is:
   {key: val, ..} func(method_name, {key: val, ...})

 * server_args:
 A server arguments hash to be passed down to the underlying core server

 * interceptors:
 Am array of GRPC::ServerInterceptor objects that will be used for
 intercepting server handlers to provide extra functionality.
 Interceptors are an EXPERIMENTAL API.

 stops a running server

 the call has no impact if the server is already stopped, otherwise
 server's current call loop is it's last.