NewPool returns a new Pool with size buckets for minSize to maxSize
(name string, minBucket, numBuckets, bktSize int)
| 30 | |
| 31 | // NewPool returns a new Pool with size buckets for minSize to maxSize |
| 32 | func NewPool(name string, minBucket, numBuckets, bktSize int) *Pool { |
| 33 | if minBucket < 0 { |
| 34 | panic("invalid min bucket size") |
| 35 | } |
| 36 | if bktSize < 1 { |
| 37 | panic("invalid bucket size") |
| 38 | } |
| 39 | if numBuckets < 1 { |
| 40 | panic("invalid num buckets") |
| 41 | } |
| 42 | |
| 43 | return &Pool{ |
| 44 | buckets: make([]sync.Pool, numBuckets), |
| 45 | bktSize: bktSize, |
| 46 | minBucket: minBucket, |
| 47 | metricMissOver: metricAllocOutPool.WithLabelValues(name, "over"), |
| 48 | metricMissUnder: metricAllocOutPool.WithLabelValues(name, "under"), |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Get returns a new byte slices that fits the given size. |
| 53 | func (p *Pool) Get(sz int) []byte { |
no outgoing calls