mirror of
https://gitee.com/openharmony/resourceschedule_ffrt
synced 2024-11-30 08:40:40 +00:00
onskip and onExcuteResult update
Signed-off-by: MaoShiwei <shiwei@ualberta.ca>
This commit is contained in:
parent
bae2c43d5b
commit
8f2c382e0e
@ -32,6 +32,7 @@ typedef enum {
|
||||
ffrt_io_task = 1,
|
||||
ffrt_uv_task, // only used to register func for libuv
|
||||
ffrt_queue_task,
|
||||
ffrt_xpu_task,
|
||||
ffrt_invalid_task
|
||||
} ffrt_executor_task_type_t;
|
||||
|
||||
|
@ -526,18 +526,7 @@ int64_t ffrt_this_queue_get_id()
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
int ffrt_skip(ffrt_task_handle_t handle)
|
||||
{
|
||||
if (!handle) {
|
||||
FFRT_LOGE("input ffrt task handle is invalid.");
|
||||
return -1;
|
||||
}
|
||||
ffrt::CPUEUTask *task = static_cast<ffrt::CPUEUTask*>(handle);
|
||||
auto exp = ffrt::SkipStatus::SUBMITTED;
|
||||
if (__atomic_compare_exchange_n(&task->skipped, &exp, ffrt::SkipStatus::SKIPPED, 0, __ATOMIC_ACQUIRE,
|
||||
__ATOMIC_RELAXED)) {
|
||||
return 0;
|
||||
}
|
||||
FFRT_LOGW("skip task [%lu] failed, because the task is executing now or has finished.", task->gid);
|
||||
return 1;
|
||||
return ffrt::FFRTFacade::GetDMInstance()::onSkip(handle);
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
|
@ -104,10 +104,12 @@ public:
|
||||
virtual void onWait(const ffrt_deps_t* deps) = 0;
|
||||
#endif
|
||||
|
||||
virtual int onExecResults(const ffrt_deps_t *deps) = 0;
|
||||
virtual int onExecResults(ffrt_task_handle_t handle) = 0;
|
||||
|
||||
virtual void onTaskDone(CPUEUTask* task) = 0;
|
||||
|
||||
virtual int onSkip(ffrt_task_handle_t handle) = 0;
|
||||
|
||||
static inline CPUEUTask* Root()
|
||||
{
|
||||
// Within an ffrt process, different threads may have different QoS interval
|
||||
|
@ -264,7 +264,7 @@ void SDependenceManager::onWait(const ffrt_deps_t* deps)
|
||||
CoWait(pendDataDepFun);
|
||||
}
|
||||
|
||||
int SDependenceManager::onExecResults(const ffrt_deps_t *deps)
|
||||
int SDependenceManager::onExecResults(ffrt_task_handle_t handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -300,6 +300,21 @@ void SDependenceManager::onTaskDone(CPUEUTask* task)
|
||||
sTask->RecycleTask();
|
||||
}
|
||||
|
||||
int SDependenceManager::onSkip(ffrt_task_handle_t handle)
|
||||
{
|
||||
FFRT_COND_DO_ERR((handle == nullptr), return ffrt_error_inval, "input ffrt task handle is invalid.");
|
||||
|
||||
ffrt::CPUEUTask *task = static_cast<ffrt::CPUEUTask*>(handle);
|
||||
auto exp = ffrt::SkipStatus::SUBMITTED;
|
||||
if (__atomic_compare_exchange_n(&task->skipped, &exp, ffrt::SkipStatus::SKIPPED, 0, __ATOMIC_ACQUIRE,
|
||||
__ATOMIC_RELAXED)) {
|
||||
return ffrt_success;
|
||||
}
|
||||
|
||||
FFRT_LOGE("skip task [%lu] failed", task->gid);
|
||||
return ffrt_error;
|
||||
}
|
||||
|
||||
void SDependenceManager::MapSignature2Deps(SCPUEUTask* task, const std::vector<const void*>& inDeps,
|
||||
const std::vector<const void*>& outDeps, std::vector<std::pair<VersionCtx*, NestType>>& inVersions,
|
||||
std::vector<std::pair<VersionCtx*, NestType>>& outVersions)
|
||||
|
@ -38,10 +38,12 @@ public:
|
||||
void onWait(const ffrt_deps_t* deps) override;
|
||||
#endif
|
||||
|
||||
int onExecResults(const ffrt_deps_t *deps) override;
|
||||
int onExecResults(ffrt_task_handle_t handle) override;
|
||||
|
||||
void onTaskDone(CPUEUTask* task) override;
|
||||
|
||||
int onSkip(ffrt_task_handle_t handle) override;
|
||||
|
||||
private:
|
||||
SDependenceManager();
|
||||
~SDependenceManager() override;
|
||||
|
Loading…
Reference in New Issue
Block a user