mirror of
https://github.com/CPunch/gopenfusion.git
synced 2025-10-13 21:00:07 +00:00
moved 'core' to 'internal'
This commit is contained in:
19
internal/protocol/pool/pool.go
Normal file
19
internal/protocol/pool/pool.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package pool
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var allocator = &sync.Pool{
|
||||
New: func() any { return new(bytes.Buffer) },
|
||||
}
|
||||
|
||||
func Get() *bytes.Buffer {
|
||||
return allocator.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
func Put(buf *bytes.Buffer) {
|
||||
buf.Reset()
|
||||
allocator.Put(buf)
|
||||
}
|
Reference in New Issue
Block a user