Skip to content
/ wheel Public
forked from things-labs/wheel

😏 golang time wheel library, which similar linux time wheel

License

Notifications You must be signed in to change notification settings

huangbug/wheel

 
 

Repository files navigation

wheel timer

golang time wheel library, which similar linux time wheel

GoDoc Build Status codecov Action Status Go Report Card Licence

Feature

  • Five-level time wheel: main level and four levels.
  • insert,delete,modify,scan item time complexity O(1).
  • the default time granularity is 1ms.
  • The maximum time is limited by the accuracy of the time base. The time granularity is 1ms, and the maximum time can be 49.71 days. so the maximum time is 49.71 days * (granularity/1ms)
  • There is the internal wheel timer base with granularity 1ms,it lazies init internal until you first used.
  • NOTE:do not use Time consuming task @ timer callback function,you can with WithGoroutine

Installation

Use go get.

    go get github.com/thinkgos/wheel

Then import the modbus package into your own code.

    import modbus "github.com/thinkgos/wheel"

Example


import (
	"log"
	"time"

	"github.com/thinkgos/wheel"
)

func main() {
	base := wheel.New()
	base.Run()

	tm := wheel.NewTimer()
	tm.WithJobFunc(func() {
		log.Println("hello world")
		base.Add(tm, time.Second)
	})
	base.Add(tm, time.Second)
	time.Sleep(time.Second * 60)
}

References


About

😏 golang time wheel library, which similar linux time wheel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.3%
  • Shell 0.7%