syncx

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "syncx"

Variables

This section is empty.

Functions

func Async

func Async(fn func() Value) chan Value

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

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 GoErr

func GoErr(err *error, fn func())

GoErr 异常处理安全并发

func GoSafe

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

GoSafe 安全并发处理

func GoTimeout

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

GoTimeout 超时处理

func SetMaxConcurrent

func SetMaxConcurrent(concurrent int64)

SetMaxConcurrent 设置最大并发数

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) Unwrap

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

type SpinLock

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

func (*SpinLock) Lock

func (sl *SpinLock) Lock()

func (*SpinLock) TryLock

func (sl *SpinLock) TryLock() bool

func (*SpinLock) Unlock

func (sl *SpinLock) Unlock()

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) SetConcurrent

func (t *WaitGroup) SetConcurrent(concurrent uint32)

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