I/E measurements

This commit is contained in:
Michal Horejsek
2020-09-11 15:09:37 +02:00
parent 41ac61bbe8
commit f3773c9d78
10 changed files with 165 additions and 18 deletions

View File

@ -62,11 +62,20 @@ func (p *Progress) update() {
return
}
// In case no one listens for an update, do not block the progress.
select {
case p.updateCh <- struct{}{}:
case <-time.After(100 * time.Millisecond):
}
// In case no one listens for an update, do not block the whole progress.
go func() {
defer func() {
// updateCh can be closed at the end of progress which is fine.
if r := recover(); r != nil {
log.WithField("r", r).Warn("Failed to send update")
}
}()
select {
case p.updateCh <- struct{}{}:
case <-time.After(5 * time.Millisecond):
}
}()
}
// finish should be called as the last call once everything is done.