async

package
v2.0.0-alpha.18 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Name = "async"

Variables

This section is empty.

Functions

func GoCtx

func GoCtx(fn func(ctx context.Context) error, parentCtx ...context.Context) context.CancelFunc

GoCtx 可取消并发处理

func GoDelay

func GoDelay(fn func() error, durations ...time.Duration)

GoDelay 异步延迟处理, 默认10ms

func GoSafe

func GoSafe(fn func() error, cb ...func(err error))

GoSafe 安全并发处理

func Timeout

func Timeout(dur time.Duration, fn func() error) error

Timeout 超时处理

Types

type Future

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

func Async

func Async[T any](fn func() (T, error)) *Future[T]

Async 异步执行函数并同步等待

func Promise

func Promise[T any](fn func(resolve func(T), reject func(err error))) *Future[T]

func (*Future[T]) Await

func (f *Future[T]) Await() result.Result[T]

type Iterator

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

func Group

func Group[T any](do func(async func(func() (T, error))) error) *Iterator[T]

func Yield

func Yield[T any](do func(yield func(T)) error) *Iterator[T]

func (*Iterator[T]) Await

func (cc *Iterator[T]) Await() result.Result[[]T]

func (*Iterator[T]) Next

func (cc *Iterator[T]) Next() (T, bool)

Jump to

Keyboard shortcuts

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