MCPcopy
hub / github.com/davyxu/cellnet / TestLoopTimer

Function TestLoopTimer

tests/timer_test.go:41–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestLoopTimer(t *testing.T) {
42
43 signal := NewSignalTester(t)
44 signal.SetTimeout(60 * time.Second)
45
46 queue := cellnet.NewEventQueue()
47
48 // 启动消息循环
49 queue.StartLoop()
50
51 var count int
52
53 // 启动计时循环
54 timer.NewLoop(queue, time.Millisecond*10, func(ctx *timer.Loop) {
55
56 log.Debugln("tick 10 ms", count)
57
58 count++
59
60 if count >= 10 {
61 signal.Done(1)
62 ctx.Stop()
63 }
64 }, nil).Start()
65
66 signal.WaitAndExpect("10ms * 10 times ticker not done", 1)
67}

Callers

nothing calls this directly

Calls 9

SetTimeoutMethod · 0.95
StartLoopMethod · 0.95
DoneMethod · 0.95
WaitAndExpectMethod · 0.95
NewEventQueueFunction · 0.92
NewLoopFunction · 0.92
NewSignalTesterFunction · 0.85
StartMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected