mirror of
https://gitee.com/openharmony/request_request
synced 2024-11-23 06:49:58 +00:00
!986 [Bug]: getTask 的任务没有 on remove 回调
Merge pull request !986 from ZhangJianxin/on_remove
This commit is contained in:
commit
d76035330c
@ -123,6 +123,7 @@ private:
|
||||
static void UvUnrefTaskContext(uv_work_t *work, int status);
|
||||
static void RegisterForegroundResume();
|
||||
static void AddTask(std::shared_ptr<ContextInfo> context);
|
||||
static void AddRemoveListener(const std::shared_ptr<ContextInfo> &context);
|
||||
bool Equals(napi_env env, napi_value value, napi_ref copy);
|
||||
|
||||
static std::mutex createMutex_;
|
||||
|
@ -202,6 +202,12 @@ int32_t JsTask::CreateExec(const std::shared_ptr<ContextInfo> &context, int32_t
|
||||
REQUEST_HILOGE("End create task in JsTask CreateExec, seq: %{public}d, failed: %{public}d", seq, ret);
|
||||
return ret;
|
||||
}
|
||||
JsTask::AddRemoveListener(context);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JsTask::AddRemoveListener(const std::shared_ptr<ContextInfo> &context)
|
||||
{
|
||||
std::string tid = context->tid;
|
||||
context->task->listenerMutex_.lock();
|
||||
context->task->notifyDataListenerMap_[SubscribeType::REMOVE] =
|
||||
@ -209,7 +215,6 @@ int32_t JsTask::CreateExec(const std::shared_ptr<ContextInfo> &context, int32_t
|
||||
context->task->listenerMutex_.unlock();
|
||||
RequestManager::GetInstance()->AddListener(
|
||||
tid, SubscribeType::REMOVE, context->task->notifyDataListenerMap_[SubscribeType::REMOVE]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
napi_value JsTask::GetCtor(napi_env env, Version version)
|
||||
@ -424,6 +429,7 @@ bool JsTask::GetTaskOutput(std::shared_ptr<ContextInfo> context)
|
||||
std::lock_guard<std::mutex> lockGuardContext(JsTask::taskContextMutex_);
|
||||
JsTask::AddTaskContextMap(tid, context);
|
||||
}
|
||||
JsTask::AddRemoveListener(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user