We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c89f81b commit 36b0ad2Copy full SHA for 36b0ad2
task_scheduler.go
@@ -176,11 +176,19 @@ func (s *TaskScheduler) checkProcessed(taskId string) bool {
176
t: time.Now(),
177
taskId: taskId,
178
}
179
- s.count++
180
s.tail++
181
if s.tail >= s.bufflen {
182
s.tail = 0
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
192
return true
193
} else {
194
return false
@@ -208,7 +216,7 @@ func (s *TaskScheduler) cleanProcessTask() {
208
216
delete(s.processedTask, s.taskProcessedTime[s.head].taskId)
209
217
s.head++
210
218
s.count--
211
- if s.head > s.bufflen {
219
212
220
s.bufflen = 0
213
221
214
222
0 commit comments