mirror of
https://github.com/tursom/GoCollections.git
synced 2025-03-16 02:50:31 +08:00
26 lines
378 B
Go
26 lines
378 B
Go
package time
|
|
|
|
import (
|
|
"time"
|
|
unsafe2 "unsafe"
|
|
|
|
"github.com/tursom/GoCollections/unsafe"
|
|
)
|
|
|
|
type Ticker struct {
|
|
time.Ticker
|
|
}
|
|
|
|
func NewTicker(d Duration) *Ticker {
|
|
return &Ticker{*time.NewTicker(d)}
|
|
}
|
|
|
|
func (t *Ticker) Stop() {
|
|
t.Ticker.Stop()
|
|
close(*unsafe.ForceCast[chan time.Time](unsafe2.Pointer(&t.C)))
|
|
}
|
|
|
|
func Tick(d Duration) <-chan Time {
|
|
return time.Tick(d)
|
|
}
|