MCPcopy
hub / github.com/grpc/grpc-go / NewBinaryTieredBufferPool

Function NewBinaryTieredBufferPool

internal/mem/buffer_pool.go:73–77  ·  view source on GitHub ↗

NewBinaryTieredBufferPool returns a BufferPool backed by multiple sub-pools. This structure enables O(1) lookup time for Get and Put operations. The arguments provided are the exponents for the buffer capacities (powers of 2), not the raw byte sizes. For example, to create a pool of 16KB buffers (2

(powerOfTwoExponents ...uint8)

Source from the content-addressed store, hash-verified

71// of 2), not the raw byte sizes. For example, to create a pool of 16KB buffers
72// (2^14 bytes), pass 14 as the argument.
73func NewBinaryTieredBufferPool(powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error) {
74 return newBinaryTiered(func(size int) bufferPool {
75 return newSizedBufferPool(size, true)
76 }, &SimpleBufferPool{shouldZero: true}, powerOfTwoExponents...)
77}
78
79// NewDirtyBinaryTieredBufferPool returns a BufferPool backed by multiple
80// sub-pools. It is similar to NewBinaryTieredBufferPool but it does not

Calls 2

newBinaryTieredFunction · 0.85
newSizedBufferPoolFunction · 0.85