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

😏 时间任务调度,主要处理周期频繁不耗时的任务,可自定义每个条目使用goroutine方式

License

Notifications You must be signed in to change notification settings

things-labs/timing

Repository files navigation

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)
}

About

😏 时间任务调度,主要处理周期频繁不耗时的任务,可自定义每个条目使用goroutine方式

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages