slicepool

package
v0.0.0-...-581961c Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LazySlice

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

LazySlice holds 0 or 1 slices from a particular Pool.

func (*LazySlice) Acquire

func (b *LazySlice) Acquire() []byte

Acquire this slice from the pool and return it. This slice must not already be acquired.

func (*LazySlice) Release

func (b *LazySlice) Release()

Release the buffer back to the pool, unless the box is empty. The caller must discard any references to the buffer.

type Pool

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

Pool wraps a sync.Pool of *[]byte. To encourage correct usage, all public methods are on slicepool.LazySlice.

All copies of a Pool refer to the same underlying pool.

"*[]byte" is used to avoid a heap allocation when passing a []byte to sync.Pool.Put, which leaks its argument to the heap.

func MakePool

func MakePool(sliceLen int) Pool

MakePool returns a Pool of slices with the specified length.

func (*Pool) LazySlice

func (p *Pool) LazySlice() LazySlice

LazySlice returns an empty LazySlice tied to this Pool.

Jump to

Keyboard shortcuts

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