mirror of
https://gitee.com/openharmony/resourceschedule_ffrt
synced 2024-11-30 08:40:40 +00:00
fix dependence problem
Signed-off-by: wangyulie <wanglieyu@126.com>
This commit is contained in:
parent
199907e68f
commit
7008f250d5
@ -228,6 +228,20 @@ FFRT_C_API void ffrt_submit_base(ffrt_function_header_t* f, const ffrt_deps_t* i
|
||||
FFRT_C_API ffrt_task_handle_t ffrt_submit_h_base(ffrt_function_header_t* f, const ffrt_deps_t* in_deps,
|
||||
const ffrt_deps_t* out_deps, const ffrt_task_attr_t* attr);
|
||||
|
||||
/**
|
||||
* @brief increase reference count of task handle.
|
||||
*
|
||||
* @param handle Indicates a task handle.
|
||||
*/
|
||||
FFRT_C_API void ffrt_task_handle_inc_ref(ffrt_task_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief decrease reference count of task handle.
|
||||
*
|
||||
* @param handle Indicates a task handle.
|
||||
*/
|
||||
FFRT_C_API void ffrt_task_handle_dec_ref(ffrt_task_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Destroys a task handle.
|
||||
*
|
||||
|
@ -224,6 +224,46 @@ struct dependence : ffrt_dependence_t {
|
||||
{
|
||||
type = ffrt_dependence_task;
|
||||
ptr = h;
|
||||
ffrt_task_handle_inc_ref(const_cast<ffrt_task_handle_t>(ptr));
|
||||
}
|
||||
|
||||
dependence(const dependence& other)
|
||||
{
|
||||
(*this) = other;
|
||||
}
|
||||
|
||||
dependence(dependence&& other)
|
||||
{
|
||||
(*this) = std::move(other);
|
||||
}
|
||||
|
||||
dependence& operator=(const dependence& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
type = other.type;
|
||||
ptr = other.ptr;
|
||||
if (type == ffrt_dependence_task) {
|
||||
ffrt_task_handle_inc_ref(const_cast<ffrt_task_handle_t>(ptr));
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
dependence& operator=(dependence&& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
type = other.type;
|
||||
ptr = other.ptr;
|
||||
other.ptr = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~dependence()
|
||||
{
|
||||
if (type == ffrt_dependence_task && ptr) {
|
||||
ffrt_task_handle_dec_ref(const_cast<ffrt_task_handle_t>(ptr));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -317,6 +317,32 @@ ffrt_task_handle_t ffrt_submit_h_base(ffrt_function_header_t *f, const ffrt_deps
|
||||
return handle;
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
void ffrt_task_handle_inc_ref(ffrt_task_handle_t handle)
|
||||
{
|
||||
if (handle == nullptr) {
|
||||
FFRT_LOGE("input task handle is invalid");
|
||||
return;
|
||||
}
|
||||
static_cast<ffrt::CPUEUTask*>(handle)->IncDeleteRef();
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
void ffrt_task_handle_dec_ref(ffrt_task_handle_t handle)
|
||||
{
|
||||
if (handle == nullptr) {
|
||||
FFRT_LOGE("input task handle is invalid");
|
||||
return;
|
||||
}
|
||||
static_cast<ffrt::CPUEUTask*>(handle)->DecDeleteRef();
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
void ffrt_task_handle_destroy(ffrt_task_handle_t handle)
|
||||
{
|
||||
ffrt_task_handle_dec_ref(handle);
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
void ffrt_task_handle_destroy(ffrt_task_handle_t handle)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user