mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-26 22:00:27 +08:00
optimize(gold): apply more buffer pools
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package head
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/fumiama/WireGold/helper"
|
||||
)
|
||||
|
||||
var packetPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
@@ -16,6 +20,12 @@ func SelectPacket() *Packet {
|
||||
// PutPacket 将 Packet 放回池中
|
||||
func PutPacket(p *Packet) {
|
||||
p.idxdatsz = 0
|
||||
p.Data = nil
|
||||
if p.buffered {
|
||||
helper.PutBytes(p.data)
|
||||
p.buffered = false
|
||||
}
|
||||
p.a, p.b = 0, 0
|
||||
p.data = nil
|
||||
p.rembytes = 0
|
||||
packetPool.Put(p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user