syncutil

package
v2.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package syncutil adds functions for synchronization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wait

func Wait(ctx context.Context, wg *sync.WaitGroup) error

Wait for a sync.WaitGroup with support for timeout/cancellations from context.

Types

type Map added in v2.1.0

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map a generic sync map.

func NewMap added in v2.1.0

func NewMap[K comparable, V any]() Map[K, V]

NewMap create a new threadsafe map.

func (*Map[K, V]) Get added in v2.1.0

func (sm *Map[K, V]) Get(k K) (V, bool)

Get a value from this map.

func (*Map[K, V]) Range added in v2.1.0

func (sm *Map[K, V]) Range(fn func(K, V) bool)

Range iterate the map.

func (*Map[K, V]) Store added in v2.1.0

func (sm *Map[K, V]) Store(k K, v V)

Store a value in this map.

Jump to

Keyboard shortcuts

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