优化限制并发的生效

This commit is contained in:
Yun
2026-05-27 14:53:26 +08:00
parent ed326b192d
commit ee90cf2e36
2 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -550,7 +550,7 @@ func (c *Cluster) executeTasks() {
return return
case <-c.ctx.Done(): case <-c.ctx.Done():
return return
case c.workerChan <- struct{}{}: default:
func() { func() {
if c.usePriority && !c.priority.IsLatest(c.ctx) { if c.usePriority && !c.priority.IsLatest(c.ctx) {
@@ -572,6 +572,9 @@ func (c *Cluster) executeTasks() {
return return
} }
// 限制并发数量
c.workerChan <- struct{}{}
go c.processTask(taskID[1]) go c.processTask(taskID[1])
}() }()
} }
+5 -2
View File
@@ -309,7 +309,7 @@ func (l *Once) executeTasks() {
return return
case <-l.ctx.Done(): case <-l.ctx.Done():
return return
case l.workerChan <- struct{}{}: default:
func() { func() {
if l.usePriority && !l.priority.IsLatest(l.ctx) { if l.usePriority && !l.priority.IsLatest(l.ctx) {
@@ -330,7 +330,10 @@ func (l *Once) executeTasks() {
l.logger.Errorf(l.ctx, "Invalid task data: %v", keys) l.logger.Errorf(l.ctx, "Invalid task data: %v", keys)
return return
} }
// 处理任务
// 限制并发数量
l.workerChan <- struct{}{}
go l.processTask(keys[1]) go l.processTask(keys[1])
}() }()
} }