mirror of https://github.com/mum4k/termdash.git
Fixing invalid use of time.Timer.
Timer fires only once. Needs to be recreated.
This commit is contained in:
parent
b53dce0412
commit
36bf99ebc7
|
@ -89,9 +89,8 @@ func (r *receiver) waitFor(want int, timeout time.Duration) (map[terminalapi.Eve
|
|||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
tick := time.NewTimer(5 * time.Millisecond)
|
||||
defer tick.Stop()
|
||||
for {
|
||||
tick := time.NewTimer(5 * time.Millisecond)
|
||||
select {
|
||||
case <-tick.C:
|
||||
ev := r.getEvents()
|
||||
|
@ -106,7 +105,7 @@ func (r *receiver) waitFor(want int, timeout time.Duration) (map[terminalapi.Eve
|
|||
|
||||
case <-ctx.Done():
|
||||
ev := r.getEvents()
|
||||
return nil, fmt.Errorf("while waiting for events, got %d so far: %v, err: %v", len(ev), ev, ctx.Err())
|
||||
return nil, fmt.Errorf("while waiting for events, got %d so far: %v, want %d, err: %v", len(ev), ev, want, ctx.Err())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -564,9 +564,8 @@ func untilEmpty(timeout time.Duration, q *eventqueue.Unbound) error {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
tick := time.NewTimer(5 * time.Millisecond)
|
||||
defer tick.Stop()
|
||||
for {
|
||||
tick := time.NewTimer(5 * time.Millisecond)
|
||||
select {
|
||||
case <-tick.C:
|
||||
if q.Empty() {
|
||||
|
|
Loading…
Reference in New Issue