(channelSize int, afterFunc func())
| 627 | } |
| 628 | |
| 629 | func (t *Timer) init(channelSize int, afterFunc func()) { |
| 630 | if channelSize <= 0 { |
| 631 | panic("ticker channel size must be non-negative") |
| 632 | } |
| 633 | c := make(chan time.Time, channelSize) |
| 634 | t.C = c |
| 635 | if afterFunc == nil { |
| 636 | t.f = func(curTime time.Time) { |
| 637 | select { |
| 638 | case c <- curTime: |
| 639 | default: |
| 640 | } |
| 641 | } |
| 642 | } else { |
| 643 | t.f = func(_ time.Time) { afterFunc() } |
| 644 | } |
| 645 | t.em.Reschedule(t, t.nextTrigger) |
| 646 | } |
| 647 | |
| 648 | // Fire triggers the ticker. curTime is the timestamp to write to the channel. |
| 649 | // The next trigger time for the ticker is updated to the last computed trigger |
no test coverage detected