You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
445 B

4 years ago
  1. package operation
  2. import (
  3. "github.com/valyala/bytebufferpool"
  4. "sync/atomic"
  5. )
  6. var bufferCounter int64
  7. func GetBuffer() *bytebufferpool.ByteBuffer {
  8. defer func() {
  9. atomic.AddInt64(&bufferCounter, 1)
  10. // println("+", bufferCounter)
  11. }()
  12. return bytebufferpool.Get()
  13. }
  14. func PutBuffer(buf *bytebufferpool.ByteBuffer) {
  15. defer func() {
  16. atomic.AddInt64(&bufferCounter, -1)
  17. // println("-", bufferCounter)
  18. }()
  19. bytebufferpool.Put(buf)
  20. }