package mem
Import Path
google.golang.org/grpc/internal/mem (on go.dev)
Dependency Relation
imports 6 packages, and imported by 2 packages
Involved Source Files
Package mem provides utilities that facilitate memory reuse in byte slices
that are used as buffers.
Package-Level Type Names (total 4)
BinaryTieredBufferPool is a buffer pool that uses multiple sub-pools with
power-of-two sizes.
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
*BinaryTieredBufferPool : google.golang.org/grpc/mem.BufferPool
func NewBinaryTieredBufferPool(powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error)
func NewDirtyBinaryTieredBufferPool(powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error)
NopBufferPool is a buffer pool that returns new buffers without pooling.
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
NopBufferPool : google.golang.org/grpc/mem.BufferPool
SimpleBufferPool is an implementation of the mem.BufferPool interface that
attempts to pool buffers with a sync.Pool. When Get is invoked, it tries to
acquire a buffer from the pool but if that buffer is too small, it returns it
to the pool and creates a new one.
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
*SimpleBufferPool : google.golang.org/grpc/mem.BufferPool
func NewDirtySimplePool() *SimpleBufferPool
TieredBufferPool implements the BufferPool interface with multiple tiers of
buffer pools for different sizes of buffers.
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
*TieredBufferPool : google.golang.org/grpc/mem.BufferPool
func NewTieredBufferPool(poolSizes ...int) *TieredBufferPool
Package-Level Functions (total 4)
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^14 bytes), pass 14 as the argument.
NewDirtyBinaryTieredBufferPool returns a BufferPool backed by multiple
sub-pools. It is similar to NewBinaryTieredBufferPool but it does not
initialize the buffers before returning them.
NewDirtySimplePool constructs a [SimpleBufferPool]. It does not initialize
the buffers before returning them. Callers must ensure they don't read the
buffers before writing data to them.
NewTieredBufferPool returns a BufferPool implementation that uses multiple
underlying pools of the given pool sizes.
Package-Level Variables (only one)
BufferPoolingThreshold is the minimum size of a buffer that can be pooled.
This is used to determine whether to pool buffers or allocate them directly.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |