62
GitHub - zheng-ji/goTimeWheel: Timer Implemented By Go,Also Called TimeWheel
source link: https://github.com/zheng-ji/goTimeWheel?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
master
Code
README.md
goTimeWheel
TimeWheel Implemented By Go. Go 实现的时间轮,俗称定时器 Link
Feature
- Effective at Space Usage
- Each Timer Can Custom Its Task
Installation
go get github.com/zheng-ji/goTimeWheel
Example
import ( "fmt" "github.com/zheng-ji/goTimeWheel" ) func main() { // timer ticker tw := goTimeWheel.New(1*time.Second, 3600) tw.Start() // "ID1" means the timer's name // Specify a function and params, it will run after 3s later name := "ID1" params := map[string]int{"age": 1} fn := func(data interface{}) { fmt.Printf("hello, %v\n", data) } tw.AddTimer(3*time.Second, name, fn, params) // Your Logic Code select{} }
License
Copyright (c) 2019 by zheng-ji released under MIT License.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK