```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(socket): 使用bytebufferpool优化内存分配并重构消息处理机制

引入bytebufferpool减少内存分配开销,在ServerEvent.go中修改数据处理逻辑,
将直接的数据拷贝改为使用缓冲池。同时移除原有的消息通道机制,改用lock
This commit is contained in:
昔念
2026-03-04 14:00:55 +08:00
parent 98c4caac68
commit fc8fc1ed8d
3 changed files with 55 additions and 71 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"github.com/lunixbochs/struc"
"github.com/valyala/bytebufferpool"
)
// TomeeHeader 结构体字段定义
@@ -16,8 +17,9 @@ type TomeeHeader struct {
UserID uint32 `json:"userId"`
//Error uint32 `json:"error" struc:"skip"`
Result uint32 `json:"result"`
Data []byte `json:"data" struc:"skip"` //组包忽略此字段// struc:"skip"
Result uint32 `json:"result"`
Data *bytebufferpool.ByteBuffer `json:"data" struc:"skip"` //组包忽略此字段// struc:"skip"
Res []byte `struc:"skip"`
//Return []byte `struc:"skip"` //返回记录
}