From cc69b262fdf9092dbd910aa210eecf487898ac7c Mon Sep 17 00:00:00 2001 From: steden <1470804@qq.com> Date: Wed, 19 Jun 2024 14:06:15 +0800 Subject: [PATCH] format --- invokeJob.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/invokeJob.go b/invokeJob.go index 6db4e77..adc52b4 100644 --- a/invokeJob.go +++ b/invokeJob.go @@ -82,21 +82,22 @@ func (receiver *Job) Run() { if entryFSchedule != nil { entryFSchedule.End() } - // 工作中任务-1 - defaultClient.WorkCount-- }() taskStartAtSince := time.Since(receiver.jobContext.StartAt) if taskStartAtSince.Microseconds() > 0 { flog.Warningf("任务组:%s %d 延迟:%s", receiver.jobContext.Name, receiver.jobContext.Id, taskStartAtSince.String()) - } - if receiver.jobContext.StartAt.After(time.Now()) { + } else { // 为了保证任务不被延迟,服务端会提前下发任务,需要客户端做休眠等待 <-timingWheel.AddTimePrecision(receiver.jobContext.StartAt).C } // 工作中任务+1 defaultClient.WorkCount++ + defer func() { + // 工作中任务-1 + defaultClient.WorkCount-- + }() // 执行任务并拿到结果 exception.Try(func() { // 通知调度中心,我开始执行了