tcp消息内存优化

This commit is contained in:
lifeiyi
2020-12-14 17:56:31 +08:00
parent a5666a6766
commit 9e11b045e2
2 changed files with 14 additions and 5 deletions

View File

@@ -5,7 +5,8 @@ import (
)
type INetMempool interface {
MakeByteSlice(size int) []byte
MakeReadByteSlice(size int) []byte
MakeWriteByteSlice(size int) []byte
ReleaseByteSlice(byteBuff []byte) bool
}
@@ -80,6 +81,14 @@ func (areaPool *memAreaPool) MakeByteSlice(size int) []byte{
return nil
}
func (areaPool *memAreaPool) MakeReadByteSlice(size int) []byte{
return areaPool.MakeByteSlice(size)
}
func (areaPool *memAreaPool) MakeWriteByteSlice(size int) []byte{
return areaPool.MakeByteSlice(size)
}
func (areaPool *memAreaPool) ReleaseByteSlice(byteBuff []byte) bool {
for i:=0;i<len(memAreaPoolList);i++{
if cap(byteBuff) <= memAreaPoolList[i].maxAreaValue {