From 9e651d30237407b04af7a1ace00f4178628af928 Mon Sep 17 00:00:00 2001 From: dengsgo Date: Sat, 17 Oct 2020 10:24:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taskman.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/taskman.go b/taskman.go index 1a2806c..a530288 100644 --- a/taskman.go +++ b/taskman.go @@ -30,14 +30,15 @@ func newTaskMan(delay int, callUrl string) *TaskMan { go func() { for { <-t.waitChan - if len(t.waitQueue) > 0 { - cf := t.waitQueue[len(t.waitQueue)-1] - if len(t.waitQueue) > 1 { - logInfo("redundant tasks dropped:", len(t.waitQueue)-1) - } - t.waitQueue = []*changedFile{} - go t.preRun(cf) + if len(t.waitQueue) < 1 { + return } + cf := t.waitQueue[len(t.waitQueue)-1] + if len(t.waitQueue) > 1 { + logInfo("redundant tasks dropped:", len(t.waitQueue)-1) + } + t.waitQueue = []*changedFile{} + go t.preRun(cf) } }() }