sync

package
v0.0.0-...-663520b Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package sync is utilities for synchronization

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TypedPool

type TypedPool[K any] struct {
	// contains filtered or unexported fields
}

TypedPool is a type-safe version of sync.Pool

func NewDefaultTypedPool

func NewDefaultTypedPool[K any]() *TypedPool[K]

NewDefaultTypedPool creates a TypedPool using the default `new` function to create instances of K

func NewSlicePool

func NewSlicePool[K any](size int, capacity int) *TypedPool[[]K]

NewSlicePool creates a TypedPool using `make` to create slices of specified size and capacity for instances of []K

func NewTypedPool

func NewTypedPool[K any](f func() *K) *TypedPool[K]

NewTypedPool creates a TypedPool using the provided function to create instances of K

func (*TypedPool[K]) Get

func (t *TypedPool[K]) Get() *K

Get wraps sync.Pool.Get in a type-safe way

func (*TypedPool[K]) Put

func (t *TypedPool[K]) Put(x *K)

Put wraps sync.Pool.Put in a type-safe way

Jump to

Keyboard shortcuts

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