!51 update timeout interfaces

Merge pull request !51 from wangyulie/master
This commit is contained in:
openharmony_ci 2023-07-29 07:08:51 +00:00 committed by Gitee
commit aae657fb1a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 11 additions and 11 deletions

View File

@ -27,8 +27,8 @@ FFRT_C_API void ffrt_queue_attr_set_qos(ffrt_queue_attr_t* attr, ffrt_qos_t qos)
FFRT_C_API ffrt_qos_t ffrt_queue_attr_get_qos(const ffrt_queue_attr_t* attr);
FFRT_C_API void ffrt_queue_attr_set_timeout(ffrt_queue_attr_t* attr, uint64_t timeout_us);
FFRT_C_API uint64_t ffrt_queue_attr_get_timeout(const ffrt_queue_attr_t* attr);
FFRT_C_API void ffrt_queue_attr_set_timeoutCb(ffrt_queue_attr_t* attr, ffrt_function_header_t* f);
FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_timeoutCb(const ffrt_queue_attr_t* attr);
FFRT_C_API void ffrt_queue_attr_set_callback(ffrt_queue_attr_t* attr, ffrt_function_header_t* f);
FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue_attr_t* attr);
// create serial queue
FFRT_C_API ffrt_queue_t ffrt_queue_create(ffrt_queue_type_t type, const char* name, const ffrt_queue_attr_t* attr);

View File

@ -60,17 +60,17 @@ public:
return ffrt_queue_attr_get_timeout(this);
}
// set timeoutCb
inline queue_attr& timeoutCb(std::function<void()>& func)
// set timeout callback
inline queue_attr& callback(std::function<void()>& func)
{
ffrt_queue_attr_set_timeoutCb(this, create_function_wrapper(func, ffrt_function_kind_queue));
ffrt_queue_attr_set_callback(this, create_function_wrapper(func, ffrt_function_kind_queue));
return *this;
}
// get timeoutCb
inline ffrt_function_header_t* timeoutCb() const
// get timeout callback
inline ffrt_function_header_t* callback() const
{
return ffrt_queue_attr_get_timeoutCb(this);
return ffrt_queue_attr_get_callback(this);
}
};

View File

@ -102,7 +102,7 @@ uint64_t ffrt_queue_attr_get_timeout(const ffrt_queue_attr_t* attr)
}
API_ATTRIBUTE((visibility("default")))
void ffrt_queue_attr_set_timeoutCb(ffrt_queue_attr_t* attr, ffrt_function_header_t* f)
void ffrt_queue_attr_set_callback(ffrt_queue_attr_t* attr, ffrt_function_header_t* f)
{
FFRT_COND_DO_ERR((attr == nullptr), return, "input invalid, attr == nullptr");
ffrt::task_attr_private* p = reinterpret_cast<ffrt::task_attr_private*>(attr);
@ -114,7 +114,7 @@ void ffrt_queue_attr_set_timeoutCb(ffrt_queue_attr_t* attr, ffrt_function_header
}
API_ATTRIBUTE((visibility("default")))
ffrt_function_header_t* ffrt_queue_attr_get_timeoutCb(const ffrt_queue_attr_t* attr)
ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue_attr_t* attr)
{
FFRT_COND_DO_ERR((attr == nullptr), return nullptr, "input invalid, attr == nullptr");
ffrt_queue_attr_t* p = const_cast<ffrt_queue_attr_t*>(attr);
@ -129,7 +129,7 @@ ffrt_queue_t ffrt_queue_create(ffrt_queue_type_t type, const char* name, const f
int qos = ffrt_queue_attr_get_qos(attr);
shared_ptr<SerialLooper> looper =
make_shared<SerialLooper>(name, qos, ffrt_queue_attr_get_timeout(attr), ffrt_queue_attr_get_timeoutCb(attr));
make_shared<SerialLooper>(name, qos, ffrt_queue_attr_get_timeout(attr), ffrt_queue_attr_get_callback(attr));
FFRT_COND_DO_ERR((looper == nullptr), return nullptr, "failed to construct SerialLooper");
SerialHandler* handler = new (std::nothrow) SerialHandler(looper);