frostfs-node/pkg/services/object/common/target/pool.go
Airat Arifullin b3deb893ba [#1310] object: Move target initialization to separate package
* Split the logic of write target initialization to different packages;
* Refactor patch and put services: since both service initialize the target
  themselves.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-09-05 13:03:58 +00:00

30 lines
447 B
Go

package target
import (
"sync"
)
const (
defaultAllocSize = 1024
poolSliceMaxSize = 128 * 1024
)
type payload struct {
Data []byte
}
var putBytesPool = &sync.Pool{
New: func() any { return &payload{Data: make([]byte, 0, defaultAllocSize)} },
}
func getPayload() *payload {
return putBytesPool.Get().(*payload)
}
func putPayload(p *payload) {
if cap(p.Data) > poolSliceMaxSize {
return
}
p.Data = p.Data[:0]
putBytesPool.Put(p)
}