threadsafe

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: LGPL-2.1 Imports: 1 Imported by: 0

Documentation

Overview

Package threadsafe provides an interface for thread-safe functions that can be safely used between multiple goroutines.

See the tsmap and tsslice packages for examples of how to use this interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker sync.Locker

Locker is an interface that implements the Lock and Unlock methods.

type RLocker

type RLocker interface {
	RLock()
	RUnlock()
}

RLocker is an interface that implements the RLock and RUnlock methods.

type SimpleSafeSlice

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

SimpleSafeSlice for simple use

func NewSimpleSlice

func NewSimpleSlice[T any](v []T) *SimpleSafeSlice[T]

NewSimpleSlice creates a new SimpleSafeSlice with initial values

func (*SimpleSafeSlice[T]) All

func (s *SimpleSafeSlice[T]) All() []T

All returns all elements in the slice

func (*SimpleSafeSlice[T]) Append

func (s *SimpleSafeSlice[T]) Append(x ...T)

Append appends elements to the slice

func (*SimpleSafeSlice[T]) Filter

func (s *SimpleSafeSlice[T]) Filter(predicate func(T) bool) []T

Filter returns a new slice containing only the elements for which the predicate returns true

func (*SimpleSafeSlice[T]) Get

func (s *SimpleSafeSlice[T]) Get(i int) T

Get retrieves the element at the specified index

func (*SimpleSafeSlice[T]) Len

func (s *SimpleSafeSlice[T]) Len() int

Len returns the length of the slice

func (*SimpleSafeSlice[T]) Map

func (s *SimpleSafeSlice[T]) Map(transform func(T) T) []T

Map returns a new slice resulting from applying the function to each element of the slice

func (*SimpleSafeSlice[T]) Reduce

func (s *SimpleSafeSlice[T]) Reduce(initial T, reducer func(T, T) T) T

Reduce applies the function to each element of the slice, returning a single result

func (*SimpleSafeSlice[T]) RemoveAt

func (s *SimpleSafeSlice[T]) RemoveAt(i int)

RemoveAt removes the element at the specified index

Directories

Path Synopsis
Package tsmap provides a collection of generic thread-safe map utility functions that can be safely used between multiple goroutines.
Package tsmap provides a collection of generic thread-safe map utility functions that can be safely used between multiple goroutines.
Package tsslice provides a collection of generic thread-safe slice utility functions that can be safely used between multiple goroutines.
Package tsslice provides a collection of generic thread-safe slice utility functions that can be safely used between multiple goroutines.

Jump to

Keyboard shortcuts

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