|
|
@ -167,15 +167,13 @@ func (j *Job) limit() bool { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更精确的控制是加锁
|
|
|
|
count := atomic.AddInt64(j.Count, 1) |
|
|
|
// 两次运行时间极为接近的任务才可能出现控制不精确的情况
|
|
|
|
if j.Parallels < count { |
|
|
|
count := atomic.LoadInt64(j.Count) |
|
|
|
atomic.AddInt64(j.Count, -1) |
|
|
|
if j.Parallels <= count { |
|
|
|
|
|
|
|
j.Fail(time.Now(), fmt.Sprintf("job[%s] running on[%s] running:[%d]", j.Key(), j.runOn, count)) |
|
|
|
j.Fail(time.Now(), fmt.Sprintf("job[%s] running on[%s] running:[%d]", j.Key(), j.runOn, count)) |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
atomic.AddInt64(j.Count, 1) |
|
|
|
|
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|