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 ¶
- type Locker
- type RLocker
- type SimpleSafeSlice
- func (s *SimpleSafeSlice[T]) All() []T
- func (s *SimpleSafeSlice[T]) Append(x ...T)
- func (s *SimpleSafeSlice[T]) Filter(predicate func(T) bool) []T
- func (s *SimpleSafeSlice[T]) Get(i int) T
- func (s *SimpleSafeSlice[T]) Len() int
- func (s *SimpleSafeSlice[T]) Map(transform func(T) T) []T
- func (s *SimpleSafeSlice[T]) Reduce(initial T, reducer func(T, T) T) T
- func (s *SimpleSafeSlice[T]) RemoveAt(i int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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. |