YTSFlix_Go/vendor/github.com/anacrolix/missinggo/timer.go

16 lines
265 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package missinggo
import (
"math"
"time"
)
// Returns a time.Timer that calls f. The timer is initially stopped.
func StoppedFuncTimer(f func()) (t *time.Timer) {
t = time.AfterFunc(math.MaxInt64, f)
if !t.Stop() {
panic("timer already fired")
}
return
}