mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-23 08:47:55 +08:00
25 lines
445 B
Go
25 lines
445 B
Go
package operation
|
|
|
|
import (
|
|
"github.com/valyala/bytebufferpool"
|
|
"sync/atomic"
|
|
)
|
|
|
|
var bufferCounter int64
|
|
|
|
func GetBuffer() *bytebufferpool.ByteBuffer {
|
|
defer func() {
|
|
atomic.AddInt64(&bufferCounter, 1)
|
|
// println("+", bufferCounter)
|
|
}()
|
|
return bytebufferpool.Get()
|
|
}
|
|
|
|
func PutBuffer(buf *bytebufferpool.ByteBuffer) {
|
|
defer func() {
|
|
atomic.AddInt64(&bufferCounter, -1)
|
|
// println("-", bufferCounter)
|
|
}()
|
|
bytebufferpool.Put(buf)
|
|
}
|