@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user