You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing this and detected a corner case where the ticker is not called if one tick is "missed" while code is executing.
The following code stops executing after the sleep is triggered.
func TestRandomTicker(t *testing.T) {
ticker := clock.NewRandomTicker(4*time.Second, 6*time.Second)
defer ticker.Stop()
var counter = 0
for {
select {
case <-ticker.C:
counter++
fmt.Printf("c %d\n", counter)
if counter > 5 {
println("sleeping for 10 seconds")
time.Sleep(10 * time.Second)
println("finished sleeping")
}
}
}
}
The problem is on the default clause in the RandomTicker loop. Replacing the Timer for a Ticker solves that since we guarantee that it will be called again.
The text was updated successfully, but these errors were encountered:
Hi,
I was testing this and detected a corner case where the ticker is not called if one tick is "missed" while code is executing.
The following code stops executing after the sleep is triggered.
The problem is on the default clause in the RandomTicker loop. Replacing the Timer for a Ticker solves that since we guarantee that it will be called again.
The text was updated successfully, but these errors were encountered: