Skip to content

Commit

Permalink
refactor(计划): 增加非固定参数
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Dec 5, 2024
1 parent d56fc4b commit b85ffbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions internal/internal/core/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@ func NewProcessor(tasker kernel.Tasker, params *param.Agent) *Processor {

func (p *Processor) Process(selector kernel.Selector) {
for {
tasks := p.tasker.Pop(p.params.Retries)
if 0 == len(tasks) { // 让出时间切片
time.Sleep(0)
continue
}

for _, _task := range tasks {
if _, exists := p.progresses.Load(_task.Id()); exists {
continue
}

_task := p.tasker.Pop(p.params.Retries)
if _, exists := p.progresses.Load(_task.Id()); exists {
time.Sleep(0) // 让出时间片
} else {
go func() {
_ = p.process(_task, selector) // 错误已经处理,纯接收
}()
Expand Down
2 changes: 1 addition & 1 deletion internal/kernel/tasker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Tasker interface {
Update(id uint64, status Status, runtime time.Time) error

// Pop 取出任务并执行
Pop(retries uint32) []Task
Pop(retries uint32) Task

// Archive 存档
Archive(task Task) error
Expand Down

0 comments on commit b85ffbd

Please sign in to comment.