diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go index 51173808e9..159966d0cb 100644 --- a/pkg/pool/pool.go +++ b/pkg/pool/pool.go @@ -35,7 +35,7 @@ type BucketedBytes struct { sizes []int maxTotal uint64 usedTotal uint64 - mtx sync.Mutex + mtx sync.RWMutex new func(s int) *[]byte } @@ -137,3 +137,10 @@ func (p *BucketedBytes) Put(b *[]byte) { p.usedTotal -= uint64(sz) } } + +func (p *BucketedBytes) UsedBytes() uint64 { + p.mtx.RLock() + defer p.mtx.RUnlock() + + return p.usedTotal +}