GITLAB

zhangqijia / Pro2DServer

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Pro2DServer
  • src
  • components
  • kafkatimer
  • timingwheel_test.go
  • 98b0736d   添加定时器, 检查心跳 Browse Code »
    zhangqijia
    2022-03-10 18:17:48 +0800  
timingwheel_test.go 384 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package kafkatimer

import (
	"fmt"
	"testing"
	"time"
)

func F()  {
	fmt.Println("I'm timer...")
}


func TestTimingWheel_Start(t *testing.T) {
	tw := NewTimingWheel(time.Millisecond, 20)
	tw.Start()
	defer tw.Stop()

	exitC := make(chan time.Time, 1)
	tw.AfterFunc(10 * time.Second, func() {
		fmt.Println("The timer fires")
		exitC <- time.Now().UTC()
	})

	fmt.Println(<-exitC)
}