chunks

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package chunks carves single values and short runs of a type from fixed-size off-heap chunks, the storage behind typedarena and pool.

Index

Constants

This section is empty.

Variables

View Source
var ErrSize = errors.New("chunk size must be positive")

ErrSize reports a chunk size that is not positive.

Functions

This section is empty.

Types

type Chunks

type Chunks[T any] struct {
	// contains filtered or unexported fields
}

Chunks hands out zeroed Ts from chunks of a fixed size. Runs longer than a chunk get a chunk of their own.

func New

func New[T any](a memory.Allocator, size int) (*Chunks[T], error)

New returns Chunks of size elements each and allocates the first one.

func (*Chunks[T]) Free

func (c *Chunks[T]) Free() error

Free releases every chunk. c must not be used afterwards.

func (*Chunks[T]) Reset

func (c *Chunks[T]) Reset() error

Reset makes all chunk memory available again, zeroed, and frees the oversized runs.

func (*Chunks[T]) Take

func (c *Chunks[T]) Take() (memory.Ref[T], error)

Take returns a reference to a new zeroed T.

func (*Chunks[T]) TakeSlice

func (c *Chunks[T]) TakeSlice(n int) ([]T, error)

TakeSlice returns n new zeroed Ts.

Jump to

Keyboard shortcuts

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