This commit is contained in:
Kevin Wan
2021-01-01 13:24:28 +08:00
committed by GitHub
parent a926cb514f
commit fc43876cc5
2 changed files with 36 additions and 2 deletions

View File

@@ -134,8 +134,7 @@ func (pe *PeriodicalExecutor) backgroundFlush() {
pe.guarded = false
pe.lock.Unlock()
// flush again to avoid missing tasks
pe.Flush()
pe.cleanup()
return
}
}
@@ -143,6 +142,22 @@ func (pe *PeriodicalExecutor) backgroundFlush() {
})
}
func (pe *PeriodicalExecutor) cleanup() {
// avoid deadlock in Add()
for {
select {
case vals := <-pe.commander:
pe.enterExecution()
pe.confirmChan <- lang.Placeholder
pe.executeTasks(vals)
default:
// flush again to avoid missing tasks
pe.Flush()
return
}
}
}
func (pe *PeriodicalExecutor) doneExecution() {
pe.waitGroup.Done()
}