示例#1
0
        /// <summary>
        /// 清理并释放资源
        /// </summary>
        public void Dispose()
        {
            CachedClient client = null;

            while (this.clientStack.TryPop(out client))
            {
                client.Dispose();
            }
        }
示例#2
0
        /// <summary>
        /// 从池中取出一个缓存客户端
        /// </summary>
        /// <exception cref="SocketException"></exception>
        /// <returns></returns>
        public CachedClient Pop()
        {
            CachedClient client = null;

            while (!this.clientStack.TryPop(out client))
            {
                this.spinWait.SpinOnce();
            }
            return(client);
        }
示例#3
0
 /// <summary>
 /// 将不现使用的缓存客户端放回池中
 /// </summary>
 /// <param name="client">缓存客户端</param>
 public void Push(CachedClient client)
 {
     this.clientStack.Push(client);
 }