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)
| 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. |
| 73 | func 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 |