xsync

package
v0.24.5 Latest Latest
Warning

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

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

Documentation

Overview

Package xsync contains synchronization utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReset

func GetReset[
	P interface {
		// Reset resets item state for re-use.
		Reset()
		*T
	},
	T any,
](p *Pool[P, T]) P

GetReset gets a P from pool and resets it.

func KeyOnce

func KeyOnce[K comparable, V any](do func(K) V) func(K) V

KeyOnce return function that calls make only once per key.

Types

type Pool

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

Pool is a typed wrapper around sync.Pool.

func NewPool

func NewPool[P *T, T any](newFunc func() P) *Pool[P, T]

func (*Pool[P, T]) Get

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

Get returns a P from pool.

func (*Pool[P, T]) Put

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

Put returns P to pool.

Jump to

Keyboard shortcuts

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