don't use closures for passing OnLost and OnAcked STREAM frame callbacks (#3833)

This commit is contained in:
Marten Seemann
2023-06-02 14:14:04 +03:00
committed by GitHub
parent ad79149738
commit f8d24ef1e9
14 changed files with 327 additions and 250 deletions

View File

@@ -11,6 +11,7 @@ import (
type Packet struct {
SendTime time.Time
PacketNumber protocol.PacketNumber
StreamFrames []StreamFrame
Frames []*Frame
LargestAcked protocol.PacketNumber // InvalidPacketNumber if the packet doesn't contain an ACK
Length protocol.ByteCount
@@ -32,6 +33,7 @@ var packetPool = sync.Pool{New: func() any { return &Packet{} }}
func GetPacket() *Packet {
p := packetPool.Get().(*Packet)
p.PacketNumber = 0
p.StreamFrames = nil
p.Frames = nil
p.LargestAcked = 0
p.Length = 0
@@ -51,5 +53,6 @@ func putPacket(p *Packet) {
putFrame(f)
}
p.Frames = nil
p.StreamFrames = nil
packetPool.Put(p)
}