- BaseTask.GetResult中成功返回结果后,结果在任务中会被删除(以免被管理的任务不必要的HOLD住对象)

This commit is contained in:
gazebo
2019-08-29 11:23:17 +08:00
parent 6c805edf92
commit 701da73a6e

View File

@@ -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) {