diff --git a/business/jxutils/tasksch/task.go b/business/jxutils/tasksch/task.go index 533c84e7c..f968eab6d 100644 --- a/business/jxutils/tasksch/task.go +++ b/business/jxutils/tasksch/task.go @@ -169,6 +169,7 @@ func (t *BaseTask) GetID() string { return t.ID } +// 此函数成功返回结果后,结果在任务中会被删除(以免被管理的任务不必要的HOLD住对象) func (t *BaseTask) GetResult(duration time.Duration) (retVal []interface{}, err error) { if t.GetStatus() >= TaskStatusEndBegin { return t.getResult(), t.GetErr() @@ -279,10 +280,12 @@ func (t *BaseTask) GetNoticeMsg() string { return t.NoticeMsg } -func (t *BaseTask) getResult() []interface{} { - t.locker.RLock() - defer t.locker.RUnlock() - return t.Result +func (t *BaseTask) getResult() (result []interface{}) { + t.locker.Lock() + defer t.locker.Unlock() + result = t.Result + t.Result = nil + return result } func (t *BaseTask) AddBatchErr(err error) {