timer.go 306 B

123456789101112131415161718
  1. package udptransfer
  2. import "time"
  3. const Millisecond = 1e6
  4. func Now() int64 {
  5. return time.Now().UnixNano()/Millisecond
  6. }
  7. func NowNS() int64 {
  8. return time.Now().UnixNano()
  9. }
  10. func NewTimerChan(d int64) <-chan time.Time {
  11. ticker := time.NewTimer(time.Duration(d) * time.Millisecond)
  12. return ticker.C
  13. }