Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Latest commit

 

History

History
63 lines (48 loc) · 1.85 KB

README.md

File metadata and controls

63 lines (48 loc) · 1.85 KB

timing

GoDoc Go.Dev reference Build Status codecov Action Status Go Report Card Licence Tag

Feature

  • job default process in a goroutine,so the job do not take too long. if you have long time job,please use WithGoroutine
  • you can define every timer use goroutine.
  • scan timeout's timer time complexity O(1)
  • not limited max timeout

Installation

Use go get.

    go get github.com/things-labs/timing

Then import the timing package into your own code.

    import "github.com/things-labs/timing"

Example


import (
	"log"
	"time"

	"github.com/things-labs/timing"
)

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

	tm := timing.NewTimer()
	tm.WithJobFunc(func() {
		log.Println("hello 1")
		base.Add(tm, time.Second)
	})

	tm1 := timing.NewTimer()
	tm1.WithJobFunc(func() {
		log.Println("hello 2")
		base.Add(tm1, time.Second * 2)
	})
	base.Add(tm, time.Second * 1)
	base.Add(tm1, time.Second * 2)
	time.Sleep(time.Second * 60)
}