5 Star 20 Fork 10

NightTC/Gobige

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
init.go 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
buguang 提交于 2024-11-29 10:11 +08:00 . 时间轮系统完善
package timerwheel
import (
"sync"
"time"
)
const (
//最小一组数据的个数
ArrayListMax = 1000
)
var (
PoolListE *sync.Pool
PoolBucket *sync.Pool
)
func init() {
PoolListE = &sync.Pool{
New: func() any {
return new(taskModel)
},
}
PoolBucket = &sync.Pool{
New: func() any {
return new(bucket)
},
}
}
type ITimer interface {
//一次任务 返回值(定时任务ID)
OnceTimer(delayTime time.Duration, callback func(...interface{}), params ...interface{}) uint64
//循环任务 返回值(定时任务ID)
LoopTimer(intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64
//循环次数任务 返回值(定时任务ID)
LoopTimerByCount(intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64
//循环延时任务 返回值(定时任务ID)
LoopDelayTimer(delayTime time.Duration, intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64
//循环任务(毫秒) 返回值(定时任务ID)
LoopDelayTimerByCount(delayTime time.Duration, intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64
//删除定时任务(非线程安全)
DeleteTimerTask(timerTaskID uint64)
//删除所有定时任务(非线程安全)
DeleteAllTimerTask()
//获取当前tick时间
GetTickTime() time.Time
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/night-tc/gobige.git
git@gitee.com:night-tc/gobige.git
night-tc
gobige
Gobige
f7245e354ed4

搜索帮助