concurrent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package threadsafe contains data structures (like maps) that can be safely used by multiple goroutines at the same time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Foreach

func Foreach[E any](concurrencyLimit int, collection []E, f func(E))

Execute a function concurrently for each element of a collection. Specify the max number of goroutines running at the same time.

Types

type Map

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

func NewMap

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

func NewMapWithValues

func NewMapWithValues[K comparable, V any](m map[K]V) *Map[K, V]

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K)

func (*Map[K, V]) DeleteUnsafe

func (m *Map[K, V]) DeleteUnsafe(key K)

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (val V, ok bool)

func (*Map[K, V]) GetUnsafe

func (m *Map[K, V]) GetUnsafe(key K) (val V, ok bool)

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

func (*Map[K, V]) Lock

func (m *Map[K, V]) Lock()

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(key K, value V)

func (*Map[K, V]) SetUnsafe

func (m *Map[K, V]) SetUnsafe(key K, value V)

func (*Map[K, V]) Unlock

func (m *Map[K, V]) Unlock()

type Set

type Set[V comparable] struct {
	Map map[V]struct{}
	// contains filtered or unexported fields
}

func NewSet

func NewSet[V comparable]() *Set[V]

func NewSetWithValues

func NewSetWithValues[V comparable](m map[V]struct{}) *Set[V]

func (*Set[V]) Add

func (s *Set[V]) Add(val V)

func (*Set[V]) AddUnsafe

func (s *Set[V]) AddUnsafe(val V)

func (*Set[V]) Contains

func (s *Set[V]) Contains(val V) bool

func (*Set[V]) ContainsUnsafe

func (s *Set[V]) ContainsUnsafe(val V) bool

func (*Set[V]) Len

func (s *Set[V]) Len() int

func (*Set[V]) Remove

func (s *Set[V]) Remove(val V)

func (*Set[V]) RemoveUnsafe

func (s *Set[V]) RemoveUnsafe(val V)

type Slice

type Slice[V any] struct {
	Slice []V
	// contains filtered or unexported fields
}

func NewSlice

func NewSlice[V any]() *Slice[V]

func NewSliceWithValues

func NewSliceWithValues[V any](s []V) *Slice[V]

func (*Slice[V]) Append

func (s *Slice[V]) Append(values ...V)

func (*Slice[V]) AppendUnsafe

func (s *Slice[V]) AppendUnsafe(values ...V)

func (*Slice[V]) Cap

func (s *Slice[V]) Cap() int

func (*Slice[V]) Get

func (s *Slice[V]) Get(index int) (val V, ok bool)

func (*Slice[V]) GetUnsafe

func (s *Slice[V]) GetUnsafe(index int) (val V, ok bool)

func (*Slice[V]) Len

func (s *Slice[V]) Len() int

func (*Slice[V]) Push

func (s *Slice[V]) Push(val V)

func (*Slice[V]) PushUnsafe

func (s *Slice[V]) PushUnsafe(val V)

func (*Slice[V]) Set

func (s *Slice[V]) Set(index int, val V) (ok bool)

func (*Slice[V]) SetUnsafe

func (s *Slice[V]) SetUnsafe(index int, val V) (ok bool)

Jump to

Keyboard shortcuts

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