Documentation ¶
Overview ¶
Package bufpool initializes an elastic pool of free buffers. Buffer have capacity common.MaxMTU.
Apps can use bufpool to ammortize allocations between multiple goroutines without preallocating a large amount of memory. Details about how the allocation and freeing of resources works can be found in the documentation for sync.Pool.
For apps where the performance penalty of grabbing a single free buffer is non-neglibile (e.g., per packet processing in a router), package ringbuf (and manual management of free buffers) should be used instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
Buffer is a container for a common.RawBytes object B. B can be safely resliced. Calling Reset will return B to its initial length and capacity.
func Get ¶
func Get() *Buffer
Get returns a buffer from the free buffer pool. If a buffer is not available, a new one is allocated.