2026-02-06 22:55:12 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import "sync"
|
|
|
|
|
|
|
|
|
|
const sseScannerBuf64KSize = 64 * 1024
|
|
|
|
|
|
|
|
|
|
type sseScannerBuf64K [sseScannerBuf64KSize]byte
|
|
|
|
|
|
|
|
|
|
var sseScannerBuf64KPool = sync.Pool{
|
|
|
|
|
New: func() any {
|
|
|
|
|
return new(sseScannerBuf64K)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getSSEScannerBuf64K() *sseScannerBuf64K {
|
2026-02-07 21:18:03 +08:00
|
|
|
v := sseScannerBuf64KPool.Get()
|
|
|
|
|
buf, ok := v.(*sseScannerBuf64K)
|
|
|
|
|
if !ok || buf == nil {
|
|
|
|
|
return new(sseScannerBuf64K)
|
|
|
|
|
}
|
|
|
|
|
return buf
|
2026-02-06 22:55:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func putSSEScannerBuf64K(buf *sseScannerBuf64K) {
|
|
|
|
|
if buf == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
sseScannerBuf64KPool.Put(buf)
|
|
|
|
|
}
|