syncx

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConcurrent = 16
View Source
const Name = "syncx"

Variables

This section is empty.

Functions

func Async

func Async(fn func() Value) chan Value

Async 通过chan的方式同步执行异步任务

func CancelCtx

func CancelCtx() (ctx context.Context, cancel context.CancelFunc)

func GoChan

func GoChan(fn func() Value) chan Value

GoChan 通过chan的方式同步执行异步任务

func GoCtx

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

GoCtx 可取消并发处理

func GoDelay

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

GoDelay 异步延迟处理

func GoSafe

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

GoSafe 安全并发处理

func Monitor

func Monitor(timeout time.Duration, run func(), errFn func(err error))

func Timeout

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

Timeout 超时处理

Types

type Promise

type Promise struct {
	// contains filtered or unexported fields
}

func Yield

func Yield(fn func() (interface{}, error)) *Promise

func YieldGroup

func YieldGroup(fn func(in chan<- *Promise) error) *Promise

func (*Promise) Await

func (t *Promise) Await() (interface{}, error)

func (*Promise) Err

func (t *Promise) Err() error

func (*Promise) Range

func (t *Promise) Range(fn func(interface{})) error

func (*Promise) Unwrap

func (t *Promise) Unwrap() <-chan interface{}

type Value

type Value interface {
	Val() interface{}
	Err() error
	IsErr() bool
}

func Wait

func Wait(val ...chan Value) []Value

func WithErr

func WithErr(err error) Value

func WithVal

func WithVal(val interface{}, err ...error) Value

type WaitGroup

type WaitGroup struct {
	Concurrent uint32
	// contains filtered or unexported fields
}

func (*WaitGroup) Add

func (t *WaitGroup) Add(delta int)

func (*WaitGroup) Count

func (t *WaitGroup) Count() uint32

func (*WaitGroup) Dec

func (t *WaitGroup) Dec()

func (*WaitGroup) Done

func (t *WaitGroup) Done()

func (*WaitGroup) Inc

func (t *WaitGroup) Inc()

func (*WaitGroup) Wait

func (t *WaitGroup) Wait()

Jump to

Keyboard shortcuts

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