/// <summary> /// If the pool implementation supports asynchronous close, then use it to avoid a blocking close call in case /// the ChannelPoolMap operations are called from an EventLoop. /// </summary> /// <param name="pool">the ChannelPool to be closed</param> /// <returns></returns> private static Task PoolCloseAsyncIfSupported(IChannelPool pool) { if (pool is SimpleChannelPool simpleChannelPool) { return(simpleChannelPool.CloseAsync()); } else { try { pool.Close(); return(TaskUtil.Completed); } catch (Exception exc) { return(TaskUtil.FromException(exc)); } } }