mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-27 07:26:35 +08:00
优化代码
This commit is contained in:
@@ -41,9 +41,9 @@ func TestTicker2(t *testing.T) {
|
||||
for {
|
||||
t.Log("loop")
|
||||
select {
|
||||
case <-ticker.C:
|
||||
case <-ticker.raw.C:
|
||||
t.Log("tick")
|
||||
case <-ticker.S:
|
||||
case <-ticker.done:
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -63,3 +63,17 @@ func TestTickerEvery(t *testing.T) {
|
||||
})
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
|
||||
func TestTicker_StopTwice(t *testing.T) {
|
||||
ticker := NewTicker(3 * time.Second)
|
||||
go func() {
|
||||
time.Sleep(10 * time.Second)
|
||||
ticker.Stop()
|
||||
ticker.Stop()
|
||||
}()
|
||||
for ticker.Next() {
|
||||
t.Log("tick")
|
||||
}
|
||||
t.Log("finished")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user