bufferpool

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Data []byte
	// contains filtered or unexported fields
}

Buffer is a slice with a pointer to Pool.

func (Buffer) Release

func (b Buffer) Release()

Release the Buffer and return it to the Pool.

type Pool

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

Pool is a wrapper around sync.Pool with a helper Release method on returned objects. Objects in the Pool are Buffers which are wrapper of a slice with a pointer to the Pool object.

func New

func New(buflen int) *Pool

New returns a new Pool for Buffers of size buflen.

func (*Pool) Get

func (p *Pool) Get(datalen int) Buffer

Get a new Buffer from the pool. datalen must not exceed buffer length given in constructor. You should release the Buffer after your work is done by calling Buffer.Release.

Jump to

Keyboard shortcuts

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