/// <summary> /// 清理并释放资源 /// </summary> public void Dispose() { CachedClient client = null; while (this.clientStack.TryPop(out client)) { client.Dispose(); } }
/// <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); }
/// <summary> /// 将不现使用的缓存客户端放回池中 /// </summary> /// <param name="client">缓存客户端</param> public void Push(CachedClient client) { this.clientStack.Push(client); }