第一版时间轮任务调度实现 #1

Merged
zhangdeman merged 15 commits from feature/timewheel into master 2023-09-04 20:13:17 +08:00
Showing only changes of commit 18cd67a9ad - Show all commits

18
core.go
View File

@ -92,9 +92,23 @@ func (tw *TimeWheel) checkAndRunTask() {
// 执行任务时Task.job是第一优先级然后是TimeWheel.job // 执行任务时Task.job是第一优先级然后是TimeWheel.job
if task.Job != nil { if task.Job != nil {
go task.Job.Execute(nil, nil) go func() {
defer func() {
if r := recover(); nil != r {
}
}()
_, _ = task.Job.Execute(nil, nil)
}()
} else if tw.Job != nil { } else if tw.Job != nil {
go tw.Job.Execute(nil, nil) go func() {
defer func() {
if r := recover(); nil != r {
}
}()
_, _ = tw.Job.Execute(nil, nil)
}()
} else { } else {
fmt.Println(fmt.Sprintf("The task %v don't have job to run", task.Key)) fmt.Println(fmt.Sprintf("The task %v don't have job to run", task.Key))
} }