Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 1.8 KB

README.md

File metadata and controls

63 lines (47 loc) · 1.8 KB

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