/// <summary> /// Removes a TCPInPacket instance from the pool. /// </summary> /// <returns>TCPInPacket removed from the pool.</returns> internal TCPInPacket Pop(TMSKSocket s, TCPCmdPacketEventHandler TCPCmdPacketEvent) { lock (this.pool) { TCPInPacket tcpInPacket = null; if (this.pool.Count <= 0) { //临时分配 tcpInPacket = new TCPInPacket() { CurrentSocket = s }; tcpInPacket.TCPCmdPacketEvent += TCPCmdPacketEvent; return(tcpInPacket); } tcpInPacket = this.pool.Pop(); tcpInPacket.CurrentSocket = s; return(tcpInPacket); } }
internal TCPInPacket Pop(TMSKSocket s, TCPCmdPacketEventHandler TCPCmdPacketEvent) { TCPInPacket result; lock (this.pool) { if (this.pool.Count <= 0) { TCPInPacket tcpInPacket = new TCPInPacket(6144) { CurrentSocket = s }; tcpInPacket.TCPCmdPacketEvent += TCPCmdPacketEvent; result = tcpInPacket; } else { TCPInPacket tcpInPacket = this.pool.Dequeue(); tcpInPacket.CurrentSocket = s; result = tcpInPacket; } } return(result); }