爱意满满的作品展示区。
orderc

Golang 版本时间轮定时器

  •  
  •   orderc · Jun 8, 2017 · 3448 views
    This topic created in 3300 days ago, the information mentioned may be changed or developed.

    项目地址

    
    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()
    }
    
    2 replies    2017-06-10 13:15:17 +08:00
    timothyye
        1
    timothyye  
       Jun 10, 2017 via Android
    刻度和槽是什么意思?
    orderc
        2
    orderc  
    OP
       Jun 10, 2017 via iPhone   ❤️ 1
    @timothyye 手机上回复不方便,参考这篇文章,http://m.blog.csdn.net/article/details?id=52420300
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5769 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 73ms · UTC 03:42 · PVG 11:42 · LAX 20:42 · JFK 23:42
    ♥ Do have faith in what you're doing.