修复 错误

This commit is contained in:
dengsgo 2020-01-02 18:32:16 +08:00
parent 7d2e8dd34d
commit 8828bcaed6

View File

@ -47,7 +47,7 @@ func newTaskMan(delay int, callUrl string) *TaskMan {
func (t *TaskMan) Put(cf *changedFile) { func (t *TaskMan) Put(cf *changedFile) {
if t.delay < 1 { if t.delay < 1 {
t.preRun(cf) t.dispatcher(cf)
return return
} }
t.putLock.Lock() t.putLock.Lock()
@ -58,20 +58,24 @@ func (t *TaskMan) Put(cf *changedFile) {
if t.lastTaskId > cf.Changed { if t.lastTaskId > cf.Changed {
return return
} }
if keyInInstruction(InstShouldFinish) { t.dispatcher(cf)
t.waitQueue = append(t.waitQueue, cf)
if t.cmd == nil {
t.waitChan <- true
return
}
logInfo("Waitting for the last task to finish")
logInfo("Number of waiting tasks:", len(t.waitQueue))
} else {
t.preRun(cf)
}
}() }()
} }
func (t *TaskMan) dispatcher(cf *changedFile) {
if keyInInstruction(InstShouldFinish) {
t.waitQueue = append(t.waitQueue, cf)
if t.cmd == nil {
t.waitChan <- true
return
}
logInfo("Waitting for the last task to finish")
logInfo("Number of waiting tasks:", len(t.waitQueue))
} else {
t.preRun(cf)
}
}
func (t *TaskMan) preRun(cf *changedFile) { func (t *TaskMan) preRun(cf *changedFile) {
if t.cmd != nil && t.cmd.Process != nil { if t.cmd != nil && t.cmd.Process != nil {
if err := t.cmd.Process.Kill(); err != nil { if err := t.cmd.Process.Kill(); err != nil {