/** * SDKPacketPool: * SDKPacket对象池 */ import SDKPacket from "./SDKPacket"; let _packets: Array = []; export default class SDKPacketPool { public static Acquire(name: string): SDKPacket { let packet: SDKPacket; if (_packets.length > 0) { packet = _packets.pop(); packet.name = name; }else{ packet = new SDKPacket(name); } return packet; } public static Release(value: SDKPacket): void { if (!value) { return; } value.reset(); _packets.push(value); } public static Destroy(): void { let index = 0, count = 0; count = _packets.length; for (index = 0; index < count; index++) { _packets[index] = null; } _packets = null; } }