1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-10 03:28:22 +08:00
Files
WireGold/gold/head/pool.go
2024-07-13 00:22:20 +09:00

22 lines
341 B
Go

package head
import "sync"
var packetPool = sync.Pool{
New: func() interface{} {
return new(Packet)
},
}
// SelectPacket 从池中取出一个 Packet
func SelectPacket() *Packet {
return packetPool.Get().(*Packet)
}
// PutPacket 将 Packet 放回池中
func PutPacket(p *Packet) {
p.idxdatsz = 0
p.Data = nil
packetPool.Put(p)
}