Skip to content

Commit

Permalink
Adjusting Memory Pool Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lxzan committed Sep 4, 2023
1 parent dcb010b commit c4db206
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions internal/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
)

const (
poolSize = 10
maxBufferSize = 256 * 1024
poolSize = 10

Lv1 = 128
Lv2 = 1024
Expand Down Expand Up @@ -41,7 +40,7 @@ func (p *BufferPool) Put(b *bytes.Buffer, index int) {
if index == 0 || b == nil {
return
}
if b.Cap() <= maxBufferSize {
if b.Cap() <= 5*p.limits[index] {
p.pools[index].Put(b)
}
}
Expand Down
4 changes: 2 additions & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (c *Conn) WriteString(s string) error {
return c.WriteMessage(OpcodeText, internal.StringToBytes(s))
}

// WriteAsync 异步写入消息
// Asynchronous Write Messages
// WriteAsync 异步非阻塞地写入消息
// Write messages asynchronously and non-blocking
func (c *Conn) WriteAsync(opcode Opcode, payload []byte) error {
frame, index, err := c.genFrame(opcode, payload)
if err != nil {
Expand Down

0 comments on commit c4db206

Please sign in to comment.