mirror of https://github.com/ouqiang/gocron
28eda835c0 | ||
---|---|---|
.. | ||
LICENSE | ||
README.md | ||
timewheel.go | ||
timewheel.jpg |
README.md
timewheel
Golang实现的时间轮
安装
go get -u github.com/ouqiang/timewheel
使用
package main
import (
"github.com/ouqiang/timewheel"
"time"
)
func main() {
// tick刻度为1秒, 3600个槽
tw := timewheel.New(1 * time.Second, 3600)
tw.Start()
tw.Add(5 * time.Second, func() {
// do something
})
tw.Add(10 * time.Minute, func() {
// do something
})
tw.Add(35 * time.Hour, func() {
// do something
})
// 停止
tw.Stop()
}