1package util
2
3import "time"
4
5type Ticker interface {
6	Channel() <-chan time.Time
7	Stop()
8}
9
10type ticker struct {
11	*time.Ticker
12}
13
14func (t *ticker) Channel() <-chan time.Time {
15	return t.C
16}
17
18func NewTicker(d time.Duration) Ticker {
19	return &ticker{time.NewTicker(d)}
20}
21
22type ManualTicker struct {
23	C chan time.Time
24}
25
26func (m *ManualTicker) Channel() <-chan time.Time {
27	return m.C
28}
29
30func (m *ManualTicker) Tick() {
31	m.C <- time.Now()
32}
33func (m *ManualTicker) Wait() {
34	<-m.C
35}
36
37func (m *ManualTicker) Stop() {
38	panic("not implemented")
39}
40
41func NewManualTicker(channelSize int) *ManualTicker {
42	return &ManualTicker{C: make(chan time.Time, channelSize)}
43}
44