1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-25 13:48:50 +08:00

Don't pop from the queue after context expiry.

This commit is contained in:
Jakub Sobon 2018-04-23 00:46:36 +01:00
parent 2d4d903f87
commit 9b5caa35f5

View File

@ -126,16 +126,15 @@ func (u *Unbound) Pull(ctx context.Context) (terminalapi.Event, error) {
u.cond.L.Lock()
defer u.cond.L.Unlock()
for {
if e := u.Pop(); e != nil {
return e, nil
}
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}
if e := u.Pop(); e != nil {
return e, nil
}
u.cond.Wait()
}
}