package main
import (
"github.com/ouqiang/timewheel"
"time"
"fmt"
)
func main() {
// tick 刻度为 1 秒, 3600 个槽, 执行的 job
tw := timewheel.New(1 * time.Second, 3600, func(data []interface{}) {
fmt.Println(data)
// do something
})
tw.Start()
tw.Add(5 * time.Second, []interface{}{1})
tw.Add(10 * time.Minute, []interface{}{2})
tw.Add(35 * time.Hour, []interface{}{3})
// 停止
tw.Stop()
}
1
timothyye 2017-06-10 12:58:36 +08:00 via Android
刻度和槽是什么意思?
|
2
orderc OP @timothyye 手机上回复不方便,参考这篇文章,http://m.blog.csdn.net/article/details?id=52420300
|