MCPcopy
hub / github.com/aceld/zinx / TestNewAutoExecTimerScheduler

Function TestNewAutoExecTimerScheduler

ztimer/timerscheduler_test.go:53–68  ·  view source on GitHub ↗

采用自动调度器运转时间轮

(t *testing.T)

Source from the content-addressed store, hash-verified

51
52// 采用自动调度器运转时间轮
53func TestNewAutoExecTimerScheduler(t *testing.T) {
54 autoTS := NewAutoExecTimerScheduler()
55
56 //给调度器添加Timer
57 for i := 0; i < 2000; i++ {
58 f := NewDelayFunc(foo, []interface{}{i, i * 3})
59 tID, err := autoTS.CreateTimerAfter(f, time.Duration(3*i)*time.Millisecond)
60 if err != nil {
61 zlog.Error("create timer error", tID, err)
62 break
63 }
64 }
65
66 //阻塞等待
67 select {}
68}
69
70// 测试取消一个定时器
71func TestCancelTimerScheduler(t *testing.T) {

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.92
NewDelayFuncFunction · 0.85
CreateTimerAfterMethod · 0.80

Tested by

no test coverage detected