feat(socket): 使用bytebufferpool优化内存分配并重构消息处理机制 引入bytebufferpool减少内存分配开销,在ServerEvent.go中修改数据处理逻辑, 将直接的数据拷贝改为使用缓冲池。同时移除原有的消息通道机制,改用lock
This commit is contained in:
@@ -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"` //返回记录
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user