MCPcopy Index your code
hub / github.com/coder/coder / pollOnce

Method pollOnce

coderd/autobuild/notify/notifier.go:98–121  ·  view source on GitHub ↗

pollOnce only returns an error so it matches the signature expected of TickerFunc nolint: revive // bare returns are fine here

()

Source from the content-addressed store, hash-verified

96// pollOnce only returns an error so it matches the signature expected of TickerFunc
97// nolint: revive // bare returns are fine here
98func (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
123func unique(ds []time.Duration) []time.Duration {
124 m := make(map[time.Duration]bool)

Callers 1

pollMethod · 0.95

Calls 3

LockMethod · 0.45
UnlockMethod · 0.45
IsZeroMethod · 0.45

Tested by

no test coverage detected