Documentation ¶
Index ¶
- Variables
- func Delay(seconds float64, fn any, args ...any)
- func Fill[S ~[]E, E any](tasks []*Task, s S, position ...int)
- func ForEach[S ~[]E, E any](args S, f func(E))
- func ForEachPtr[S ~[]E, E any](args S, f func(*E))
- func ForEachPtrV[S ~[]E, E any, V any](args S, f func(*E) V) []V
- func ForEachV[S ~[]E, E any, V any](args S, f func(E) V) []V
- func ForFunc[E any](arg E, f ...func(E))
- func ForFuncV[E any, V any](arg E, f ...func(E) V) []V
- func Loop(f func(loop EventLoop))
- func Map[M ~map[K]V, K comparable, V any](m M, f func(K, V))
- func MapR[M ~map[K]V, K comparable, V any, R any](m M, f func(K, V) R) []R
- func Promise(fn any, args ...any) (p *promise)
- func PromiseTask(task *Task) *promise
- func Results[E any](tasks []*Task, position ...int) []E
- func Retry(times int, delay float64, f func() bool) bool
- func RetryError(times int, delay float64, f func() error) bool
- func RetryErrorTask(times int, delay float64, task *Task) bool
- func RetryTask(times int, delay float64, task *Task) bool
- func RunForever(tasks ...*Task)
- func RunUntilComplete(tasks ...*Task)
- func SetEventLoop(fn func() EventLoop)
- func Wait(tasks ...*Task)
- func WaitGroup(delta int, f func(done func()))
- type AbstractEventLoop
- func (loop *AbstractEventLoop) CreateTask(fn any, args ...any) (r *Task)
- func (loop *AbstractEventLoop) Finish()
- func (loop *AbstractEventLoop) Run(task *Task)
- func (loop *AbstractEventLoop) RunForever(tasks ...*Task)
- func (loop *AbstractEventLoop) RunUntilComplete(tasks ...*Task)
- func (loop *AbstractEventLoop) Start()
- func (loop *AbstractEventLoop) Stop()
- type EventLoop
- type Status
- type Task
- func (t *Task) AddDoneCallback(c func(*Task)) *Task
- func (t *Task) Bool() bool
- func (t *Task) Bool2() bool
- func (t *Task) Check() bool
- func (t *Task) Check2() bool
- func (t *Task) Copy(args ...any) *Task
- func (t *Task) Default(args ...any) *Task
- func (t *Task) Delay(seconds float64) *Task
- func (t *Task) Done() bool
- func (t *Task) Error() error
- func (t *Task) Error2() error
- func (t *Task) First() any
- func (t *Task) Reflect(args reflect.Value) *Task
- func (t *Task) Result() []any
- func (t *Task) Run() *Task
- func (t *Task) Second() any
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoResult = errors.New("task has no rusult") ErrNoSecondResult = errors.New("task has no second rusult") )
View Source
var NewEventLoop = func() EventLoop { return &AbstractEventLoop{ status: Stop, tasks: sync.WaitGroup{}, } }
Functions ¶
func ForEachPtr ¶ added in v0.12.0
func ForEachPtr[S ~[]E, E any](args S, f func(*E))
func ForEachPtrV ¶ added in v0.13.0
func Map ¶
func Map[M ~map[K]V, K comparable, V any](m M, f func(K, V))
func MapR ¶ added in v0.13.0
func MapR[M ~map[K]V, K comparable, V any, R any](m M, f func(K, V) R) []R
func PromiseTask ¶ added in v0.12.0
func PromiseTask(task *Task) *promise
func RetryError ¶
重试函数 通过是否抛出 error 判断
func RetryErrorTask ¶ added in v0.12.0
重试函数 通过是否抛出 error 判断 支持参数
func RunForever ¶ added in v0.12.0
func RunForever(tasks ...*Task)
func RunUntilComplete ¶ added in v0.12.0
func RunUntilComplete(tasks ...*Task)
func SetEventLoop ¶
func SetEventLoop(fn func() EventLoop)
Types ¶
type AbstractEventLoop ¶
type AbstractEventLoop struct {
// contains filtered or unexported fields
}
func (*AbstractEventLoop) CreateTask ¶
func (loop *AbstractEventLoop) CreateTask(fn any, args ...any) (r *Task)
func (*AbstractEventLoop) Finish ¶ added in v0.12.0
func (loop *AbstractEventLoop) Finish()
func (*AbstractEventLoop) Run ¶ added in v0.7.0
func (loop *AbstractEventLoop) Run(task *Task)
func (*AbstractEventLoop) RunForever ¶
func (loop *AbstractEventLoop) RunForever(tasks ...*Task)
func (*AbstractEventLoop) RunUntilComplete ¶
func (loop *AbstractEventLoop) RunUntilComplete(tasks ...*Task)
func (*AbstractEventLoop) Start ¶ added in v0.12.0
func (loop *AbstractEventLoop) Start()
func (*AbstractEventLoop) Stop ¶ added in v0.12.0
func (loop *AbstractEventLoop) Stop()
type EventLoop ¶ added in v0.12.0
type EventLoop interface { CreateTask(fn any, args ...any) *Task Run(task *Task) Start() RunUntilComplete(tasks ...*Task) RunForever(tasks ...*Task) Stop() }
func GetEventLoop ¶
func GetEventLoop() EventLoop
type Task ¶
type Task struct { Func reflect.Value Args []reflect.Value // contains filtered or unexported fields }
func CreateTask ¶ added in v0.12.0
func (*Task) AddDoneCallback ¶ added in v0.12.0
Click to show internal directories.
Click to hide internal directories.