1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-07 00:40:26 +08:00
Files
WireGold/gold/head/pool.go
2022-04-13 11:34:14 +08:00

22 lines
346 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.TeaTypeDataSZ = 0
p.Data = nil
packetPool.Put(p)
}