Popularity
0.5
Growing
Activity
0.0
-
3
1
0

Programming language: Go
License: BSD 3-clause "New" or "Revised" License
Tags: Utilities    

tik alternatives and similar packages

Based on the "Utilities" category.
Alternatively, view tik alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of tik or a related project?

Add another 'Utilities' Package

README

tik

Documentation GitHub issues license Release


hierarchical timing wheel made easy

simplified version of timeout in Golang

for documentation, view the [API reference](./doc.md)

Install

go get github.com/andy2046/tik

Usage

package main

import (
    "sync"
    "time"

    "github.com/andy2046/tik"
)

func main() {
    var l sync.RWMutex
    // init a new instance
    tk := tik.New()
    i := 0
    cb := func() {
        l.Lock()
        i++
        l.Unlock()
    }
    // schedule to run cb in 500ms
    to := tk.Schedule(500, cb)

    if !to.Pending() {
        panic("it should be pending")
    }

    if to.Expired() {
        panic("it should NOT be expired")
    }

    for {
        time.Sleep(100 * time.Millisecond)

        if tk.AnyPending() {
            continue
        }

        if tk.AnyExpired() {
            continue
        }

        break
    }

    l.RLock()
    defer l.RUnlock()

    if i != 1 {
        panic("fail to callback", i)
    }
}


*Note that all licence references and agreements mentioned in the tik README section above are relevant to that project's source code only.