syncx

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package syncx provides some useful synchronization primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicValue

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

AtomicValue is a strongly typed version of sync/atomic.Value

func Value

func Value[T any](v *T) *AtomicValue[T]

Value returns a new Value

func (*AtomicValue[T]) Set

func (v *AtomicValue[T]) Set(fn func(value *T))

Set sets the value

type Pool

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

Pool is a strongly typed version of sync.Pool from go standard library

func NewPool

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

func (*Pool[T]) Get

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

Get returns an arbitrary item from the pool.

func (*Pool[T]) Put

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

Put places an item in the pool

Jump to

Keyboard shortcuts

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