File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ type lookupIterator struct {
153153 cancel func ()
154154 lookup * lookup
155155 tabRefreshing <- chan struct {}
156+ lastWait time.Time
156157}
157158
158159type lookupFunc func (ctx context.Context ) * lookup
@@ -220,6 +221,21 @@ func (it *lookupIterator) lookupFailed(tab *Table, timeout time.Duration) {
220221 return
221222 }
222223
224+ // Ensure we trigger refresh at most every 2s.
225+ const minInterval = 2 * time .Second
226+ now := time .Now ()
227+ diff := now .Sub (it .lastWait )
228+ it .lastWait = now
229+ if diff < minInterval {
230+ wait := time .NewTimer (diff )
231+ defer wait .Stop ()
232+ select {
233+ case <- wait .C :
234+ case <- tout .Done ():
235+ return
236+ }
237+ }
238+
223239 // Wait for ongoing refresh operation, or trigger one.
224240 if it .tabRefreshing == nil {
225241 it .tabRefreshing = tab .refresh ()
You can’t perform that action at this time.
0 commit comments