Skip to content

Commit 36b0ad2

Browse files
author
willzhen
committed
Fixed bug
1 parent c89f81b commit 36b0ad2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

task_scheduler.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,19 @@ func (s *TaskScheduler) checkProcessed(taskId string) bool {
176176
t: time.Now(),
177177
taskId: taskId,
178178
}
179-
s.count++
180179
s.tail++
181180
if s.tail >= s.bufflen {
182181
s.tail = 0
183182
}
183+
if s.count >= s.bufflen {
184+
// 满了, head 被覆盖
185+
s.head++
186+
if s.head >= s.bufflen {
187+
s.head = 0
188+
}
189+
} else {
190+
s.count++
191+
}
184192
return true
185193
} else {
186194
return false
@@ -208,7 +216,7 @@ func (s *TaskScheduler) cleanProcessTask() {
208216
delete(s.processedTask, s.taskProcessedTime[s.head].taskId)
209217
s.head++
210218
s.count--
211-
if s.head > s.bufflen {
219+
if s.head >= s.bufflen {
212220
s.bufflen = 0
213221
}
214222
} else {

0 commit comments

Comments
 (0)