arena

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 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 Arena

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

Arena is a generic arena allocator that pre-allocates a slice and provides goroutine-safe allocation of individual items or batches

func New

func New[T any](capacity uint64) *Arena[T]

New creates a new arena with the specified capacity

func (*Arena[T]) Alloc

func (a *Arena[T]) Alloc() (*T, bool)

Alloc allocates a single item from the arena. Returns a pointer to the item and true if allocated from arena, or a pointer to a heap-allocated item and false if arena is full.

func (*Arena[T]) AllocN

func (a *Arena[T]) AllocN(n uint64) ([]T, bool)

AllocN allocates n items from the arena. Returns a slice of the items and true if all allocated from arena, or a heap-allocated slice and false if arena doesn't have enough space.

func (*Arena[T]) Reset

func (a *Arena[T]) Reset()

Jump to

Keyboard shortcuts

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