bufferpool

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bufferpool provides a simple buffer pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

type BufferPool struct {
	// contains filtered or unexported fields
}

BufferPool provides a buffer pool that may help reduce memory allocations and GC overhead. BufferPool uses multiple underlying pools of different sizes and a fallback pool.

func New

func New(sizeClasses ...int) *BufferPool

New creates a BufferPool with the underlying pools of given sizes and a fallback pool. If sizeClasses are not provided, only the fallback pool will be created.

func (*BufferPool) Get

func (p *BufferPool) Get(size int) *[]byte

Get returns a buffer with specified length from the pool.

func (*BufferPool) Put

func (p *BufferPool) Put(buf *[]byte)

Put returns a buffer to the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL