优化concurrent模块,新增返回值控制是否回调

This commit is contained in:
duanhf2012
2023-03-31 15:12:27 +08:00
parent 7ab6c88f9c
commit 18fff3b567
3 changed files with 44 additions and 20 deletions

View File

@@ -12,7 +12,7 @@ import (
type task struct {
queueId int64
fn func()
fn func() bool
cb func(err error)
}
@@ -60,17 +60,18 @@ func (w *worker) exec(t *task) {
cb(errors.New(errString))
}
w.endCallFun(t)
w.endCallFun(true,t)
log.SError("core dump info[", errString, "]\n", string(buf[:l]))
}
}()
t.fn()
w.endCallFun(t)
w.endCallFun(t.fn(),t)
}
func (w *worker) endCallFun(t *task) {
w.pushAsyncDoCallbackEvent(t.cb)
func (w *worker) endCallFun(isDocallBack bool,t *task) {
if isDocallBack {
w.pushAsyncDoCallbackEvent(t.cb)
}
if t.queueId != 0 {
w.pushQueueTaskFinishEvent(t.queueId)