Ejemplo n.º 1
0
        /// <summary>
        /// Requests server shutdown and when there are no more calls being serviced,
        /// cleans up used resources. The returned task finishes when shutdown procedure
        /// is complete.
        /// </summary>
        public async Task ShutdownAsync()
        {
            lock (myLock)
            {
                GrpcPreconditions.CheckState(startRequested);
                GrpcPreconditions.CheckState(!shutdownRequested);
                shutdownRequested = true;
            }

            handle.ShutdownAndNotify(HandleServerShutdown, environment);
            await shutdownTcs.Task.ConfigureAwait(false);

            DisposeHandle();

            await Task.Run(() => GrpcEnvironment.Release()).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Waits until there are no more active calls for this channel and then cleans up
        /// resources used by this channel.
        /// </summary>
        public async Task ShutdownAsync()
        {
            lock (myLock)
            {
                Preconditions.CheckState(!shutdownRequested);
                shutdownRequested = true;
            }

            var activeCallCount = activeCallCounter.Count;

            if (activeCallCount > 0)
            {
                Logger.Warning("Channel shutdown was called but there are still {0} active calls for that channel.", activeCallCount);
            }

            handle.Dispose();

            await Task.Run(() => GrpcEnvironment.Release());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Requests server shutdown while cancelling all the in-progress calls.
        /// The returned task finishes when shutdown procedure is complete.
        /// </summary>
        public async Task KillAsync()
        {
            lock (myLock)
            {
                GrpcPreconditions.CheckState(startRequested);
                GrpcPreconditions.CheckState(!shutdownRequested);
                shutdownRequested = true;
            }

            var cq = environment.CompletionQueues.First();  // any cq will do

            handle.ShutdownAndNotify(HandleServerShutdown, cq);
            handle.CancelAllCalls();
            await shutdownTcs.Task.ConfigureAwait(false);

            DisposeHandle();

            await Task.Run(() => GrpcEnvironment.Release()).ConfigureAwait(false);
        }