mirror of
https://gitee.com/openharmony/resourceschedule_ffrt
synced 2024-12-02 10:26:58 +00:00
!51 update timeout interfaces
Merge pull request !51 from wangyulie/master
This commit is contained in:
commit
aae657fb1a
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user