pollOnce only returns an error so it matches the signature expected of TickerFunc nolint: revive // bare returns are fine here
()
| 96 | // pollOnce only returns an error so it matches the signature expected of TickerFunc |
| 97 | // nolint: revive // bare returns are fine here |
| 98 | func (n *Notifier) pollOnce() (_ error) { |
| 99 | tick := n.clock.Now() |
| 100 | n.lock.Lock() |
| 101 | defer n.lock.Unlock() |
| 102 | |
| 103 | deadline, callback := n.condition(tick) |
| 104 | if deadline.IsZero() { |
| 105 | return |
| 106 | } |
| 107 | |
| 108 | timeRemaining := deadline.Sub(tick) |
| 109 | for _, tock := range n.countdown { |
| 110 | if n.notifiedAt[tock] { |
| 111 | continue |
| 112 | } |
| 113 | if timeRemaining > tock { |
| 114 | continue |
| 115 | } |
| 116 | callback() |
| 117 | n.notifiedAt[tock] = true |
| 118 | return |
| 119 | } |
| 120 | return |
| 121 | } |
| 122 | |
| 123 | func unique(ds []time.Duration) []time.Duration { |
| 124 | m := make(map[time.Duration]bool) |