siddontang.golib/time2/ticker.go

31 lines
459 B
Go
Raw Normal View History

2014-09-13 17:00:14 +08:00
package time2
2014-04-15 16:36:20 +08:00
import (
"time"
)
type Ticker struct {
C <-chan time.Time
r *timer
}
func NewTicker(d time.Duration) *Ticker {
return defaultWheel.NewTicker(d)
}
func TickFunc(d time.Duration, f func()) *Ticker {
return defaultWheel.TickFunc(d, f)
}
func Tick(d time.Duration) <-chan time.Time {
return defaultWheel.Tick(d)
}
func (t *Ticker) Stop() {
t.r.w.delTimer(t.r)
}
func (t *Ticker) Reset(d time.Duration) {
t.r.w.resetTimer(t.r, d, d)
}