tik
Simple and easy timing wheel package for Go
About tik
tik
hierarchical timing wheel made easy
simplified version of timeout in Golang
for documentation, view the API reference
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)
}
}
Frequently Asked Questions
What is tik?
tik is a Utilities library for the Go programming language. Simple and easy timing wheel package for Go
How do I install tik?
Install tik with the Go module system using `go get andy2046/tik`. Check the repository for the current installation instructions.
What category does tik belong to?
tik is listed under Utilities, specifically Utilities.