# Functions
DoAll 串行执行直到遇到第1个失败任务,返回第1个错误.
DoAny 串行执行直到遇到第1个成功任务,如果全部失败返回最后1个错误.
DoCancelableAll 串行执行直到遇到第1个失败任务或ctx取消,返回第1个错误.
DoCancelableAny 串行执行直到遇到第1个成功任务或ctx取消,如果全部失败返回最后1个错误.
执行可取消任务.
执行可超时任务.
循环执行任务直到取消.
循环执行任务直到超时.
确保传入的任务已全部执行完成.
确保传入的任务已运行.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ctx可以为nil.
No description provided by the author
创建门闩.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
创建定时任务执行帮助类,传入定时间隔.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewTimerExecutor 创建执行器 period tick触发周期 bucketsNum 保存定时任务bucket数量 如果period=1s,bucketsNum=60,则遍历1次全部bucket需要60s 每次tick启动1个后台协程执行当前bucket里的任务,handler需自行决定是否启用多协程加快任务处理速度 执行器实现time wheel以提高定时器性能,但不能保证定时精度。如period=10s,任务延迟1秒执行,则任务可能在0-10s内任意时刻执行.
No description provided by the author
No description provided by the author
执行任务.
RunAll 并行执行直到遇到第1个失败任务,返回第1个错误.
RunAny 并行执行直到遇到第1个成功任务,如果全部失败返回最后1个错误.
执行可取消任务.
RunCancelableAll 并行执行直到遇到第1个失败任务或ctx取消,返回第1个错误.
RunCancelableAny 并行执行直到遇到第1个成功任务或ctx取消,如果全部失败返回最后1个错误.
执行可取消定时任务.
执行可取消任务.
执行任务.
执行可超时任务.
执行可超时定时任务.
执行可超时任务.
循环执行任务直到取消 在多协程互相协作情况下,如需ctx.Done()后立刻退出,建议使用for-select 否则task可能多执行1次。这是因为前者阻塞在task,后者阻塞在select.
循环执行任务直到超时.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
BaseResult Result实现类.
Blocker 暂未使用:WaitGroup+ValueHolder todo 考虑改写为future,提供错误和正常返回.
BlockGroup 阻塞组,可用于同步等待异步请求结果.
CacheGroup 缓存任务组,执行任务获取其返回值作为缓存,下次获取直接返回缓存值 使用single flight设计模式,避免击穿缓存。即仅在没有对应缓存时才执行第1个请求添加的任务去获取缓存值.
No description provided by the author
内部使用,解决任务执行过程中context.Context完成导致任务的ctx.Done()执行2次问题.
Latch 门闩,如果已关闭则调用latch.Wait()将阻塞当前线程,直到调用latch.Open() 如果调用sync.WaitGroup:wait()->add(),可能会报崩溃错误,必须等上次等待的协程全部释放后才能再次调用add(),即可理解为wg不可重用.
PeriodBarrier 每个周期最多执行1次函数.
No description provided by the author
No description provided by the author
RoutineGroup 多协程执行同1个任务.
定时任务执行帮助类。支持设置首次执行延时,最大重试次数等.
No description provided by the author
No description provided by the author
No description provided by the author
TaskRunner 任务执行者,用于执行BgTask.
Ticker 定时器 满足以下条件会触发tick: - currentCount>=maxCount - ticker fired && currentCount>=minCount && time.Since(lastTickTime)>=minDelay.
No description provided by the author
No description provided by the author
TimerExecutor 超时事件执行器,内部使用TimeWheel触发timeout事件 基本流程:每次tick事件,处理1个bucket里的全部timer.
No description provided by the author
WorkerGroup 多协程执行不同任务.
# Interfaces
BgTask 后台任务,执行完成应关闭返回的管道 接口实现必须满足以下条件: - Run()不行长时间阻塞调用协程,建议此方法只做初始化,然后启动另1后台协程执行具体任务 - 任务初始化时应监听ctx.Done(),在ctx取消后关闭返回的管道 - 任务执行完成后应关闭返回的管道
建议配合使用async.RunXX(),可参考示例.
任务执行上下文.
No description provided by the author
Result 任务执行结果 Value()返回任务执行结果的值,同时提供Bool()/Int()等帮助方法将结果值转换为对应的数据类型 目前实现仅使用简单的数据类型转换,如Int()基本等价于Value().(int),但转换失败返回util.TypeCastErr.
No description provided by the author
任务接口.
# Type aliases
No description provided by the author
No description provided by the author
任务函数,实现了Task接口.
No description provided by the author
No description provided by the author