xsync

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package xsync provides strongly typed concurrency primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a generic wrapper around sync.Pool. It enforces zero-allocation object reuse by eliminating the interface{} (any) boxing and type assertion overhead required by the standard library pool.

func NewPool

func NewPool[T any](factory func() *T) *Pool[T]

NewPool creates a new typed pool. The factory must return a pointer.

func (*Pool[T]) Get

func (p *Pool[T]) Get() *T

Get retrieves a pooled item.

func (*Pool[T]) Put

func (p *Pool[T]) Put(item *T)

Put returns an item to the pool. Callers MUST reset the item's state before returning it to avoid data contamination.

Jump to

Keyboard shortcuts

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