第一版时间轮任务调度实现 #1
18
core.go
18
core.go
@ -92,9 +92,23 @@ func (tw *TimeWheel) checkAndRunTask() {
|
||||
|
||||
// 执行任务时,Task.job是第一优先级,然后是TimeWheel.job
|
||||
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 {
|
||||
go tw.Job.Execute(nil, nil)
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); nil != r {
|
||||
|
||||
}
|
||||
}()
|
||||
_, _ = tw.Job.Execute(nil, nil)
|
||||
}()
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf("The task %v don't have job to run", task.Key))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user