mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
24 lines
444 B
Go
24 lines
444 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)
|
||
|
}
|