concurrent

package
v4.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package concurrent used to process concurrent request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSingleGroup

func NewSingleGroup[T any]() *singleGroup[T]

NewSingleGroup instance singleGroup

Types

type Result added in v4.10.0

type Result[T any] struct {
	Value T
	Err   error
}

Result is the results of task.

func ForEach added in v4.10.0

func ForEach[T any, R any](ctx context.Context, items []T, maxWorker int,
	fn func(context.Context, T) (R, error)) []Result[R]

ForEach iterates over elements of list and invokes iter function for each element.

type Slice

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

Slice is a slice wrapper for safe concurrency

func (*Slice[T]) Append

func (s *Slice[T]) Append(e ...T)

Append appends elements to the end of the Slice

func (*Slice[T]) Cut

func (s *Slice[T]) Cut(low, high int) error

Cut cuts the Slice by the given low and high index

func (*Slice[T]) Get

func (s *Slice[T]) Get(index int) T

Get gets the value of given index, NOTE that if index is out of range, will return zero value of T.

func (*Slice[T]) Len

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

Len gets the length of Slice

func (*Slice[T]) Reset

func (s *Slice[T]) Reset()

Reset sets the base slice to nil

func (*Slice[T]) Values

func (s *Slice[T]) Values() []T

Values gets a copy values of the base slice

Jump to

Keyboard shortcuts

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