pool.go 402 B

1234567891011121314151617181920212223
  1. package utils
  2. import "sync"
  3. const poolSize = 64 * 1024
  4. const poolSizeSmall = 10
  5. const poolSizeCopy = 32 * 1024
  6. var bufPool = sync.Pool{
  7. New: func() interface{} {
  8. return make([]byte, poolSize)
  9. },
  10. }
  11. var bufPoolSmall = sync.Pool{
  12. New: func() interface{} {
  13. return make([]byte, poolSizeSmall)
  14. },
  15. }
  16. var bufPoolCopy = sync.Pool{
  17. New: func() interface{} {
  18. return make([]byte, poolSizeCopy)
  19. },
  20. }