From a6495fede3fe8fadc6795a74a5bd982215354897 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Wed, 10 Apr 2024 11:00:08 +0800 Subject: [PATCH 01/10] update ffrt interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/loop.h | 130 +++++++++++++++++++++++++++++ resourceschedule/ffrt/c/mutex.h | 56 +++++++++++++ resourceschedule/ffrt/c/queue.h | 39 ++++++++- resourceschedule/ffrt/c/sleep.h | 1 + resourceschedule/ffrt/c/task.h | 37 ++++++++ resourceschedule/ffrt/c/timer.h | 68 +++++++++++++++ resourceschedule/ffrt/c/type_def.h | 44 +++++++++- 7 files changed, 373 insertions(+), 2 deletions(-) create mode 100644 resourceschedule/ffrt/c/loop.h create mode 100644 resourceschedule/ffrt/c/timer.h diff --git a/resourceschedule/ffrt/c/loop.h b/resourceschedule/ffrt/c/loop.h new file mode 100644 index 000000000..9a07d538e --- /dev/null +++ b/resourceschedule/ffrt/c/loop.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Ffrt + * @{ + * + * @brief ffrt provides APIs. + * + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * + * @since 12 + */ + +/** + * @file loop.h + * + * @brief Declares the loop interfaces in C. + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * @since 12 + * @version 1.0 + */ + +#ifndef FFRT_API_C_LOOP_H +#define FFRT_API_C_LOOP_H + +#include "queue.h" +#include "type_def.h" + +typedef void* ffrt_loop_t; + +/** + * @brief Creates a loop + * + * @param queue Indicates a queue. + * @return Returns a non-null loop handle if the loop is created; + * Returns a null pointer otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API ffrt_loop_t ffrt_loop_create(ffrt_queue_t queue); + +/** + * @brief Destorys a loop + * + * @param loop Indicates a loop handle. + * @return Returns 0 if the loop is destoryed; + * Returns -1 otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API int ffrt_loop_destroy(ffrt_loop_t loop); + +/** + * @brief start loop run + * + * @param loop Indicates a loop handle. + * @return Returns -1 if loop run fail; + * Returns 0 otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API int ffrt_loop_run(ffrt_loop_t loop); + +/** + * @brief stop loop run + * + * @param loop Indicates a loop handle. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API void ffrt_loop_stop(ffrt_loop_t loop); + +/** + * @brief control an epoll file descriptor on ffrt loop + * + * @param loop Indicates a loop handle. + * @param op Indicates operation on the target file descriptor. + * @param fd Indicates the target file descriptor on which to perform the operation. + * @param events Indicates the event type associated which the target file descriptor. + * @param data Indicates user data used in cb. + * @param cb Indicates user cb which will be executed when the target fd is polled. + * @return Returns 0 if success; + * Returns -1 otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API int ffrt_loop_epoll_ctl(ffrt_loop_t loop, int op, int fd, uint32_t events, void* data, ffrt_poller_cb cb); + +/** + * @brief Start a timer on ffrt loop + * + * @param loop Indicates a loop handle. + * @param timeout Indicates the number of milliseconds that specifies timeout. + * @param data Indicates user data used in cb. + * @param cb Indicates user cb which will be executed when timeout. + * @param repeat Indicates whether to repeat this timer. + * @return Returns a timer handle. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API ffrt_timer_t ffrt_loop_timer_start(ffrt_loop_t loop, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat); + +/** + * @brief Stop a target timer on ffrt loop + * + * @param loop Indicates a loop handle. + * @param handle Indicates the target timer handle. + * @return Returns 0 if success=; + * Returns -1 otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API int ffrt_loop_timer_stop(ffrt_loop_t loop, ffrt_timer_t handle); + +#endif \ No newline at end of file diff --git a/resourceschedule/ffrt/c/mutex.h b/resourceschedule/ffrt/c/mutex.h index b914fd316..5bb9d2356 100644 --- a/resourceschedule/ffrt/c/mutex.h +++ b/resourceschedule/ffrt/c/mutex.h @@ -93,4 +93,60 @@ FFRT_C_API int ffrt_mutex_trylock(ffrt_mutex_t* mutex); * @version 1.0 */ FFRT_C_API int ffrt_mutex_destroy(ffrt_mutex_t* mutex); + +/** + * @brief Initializes a recursive mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @param attr Indicates a pointer to the mutex attribute. + * @return Returns ffrt_thrd_success if the mutex is initialized; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_recursive_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr); + +/** + * @brief Locks a recursive mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is locked; + returns ffrt_thrd_error or blocks the calling thread otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_recursive_mutex_lock(ffrt_mutex_t* mutex); + +/** + * @brief Unlocks a recursive mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is unlocked; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_recursive_mutex_unlock(ffrt_mutex_t* mutex); + +/** + * @brief Attempts to lock a recursive mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is locked; + returns ffrt_thrd_error or ffrt_thrd_busy otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_recursive_mutex_trylock(ffrt_mutex_t* mutex); + +/** + * @brief Destroys a recursive mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is destroyed; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_recursive_mutex_destroy(ffrt_mutex_t* mutex); #endif diff --git a/resourceschedule/ffrt/c/queue.h b/resourceschedule/ffrt/c/queue.h index 0ee3d375a..014244372 100644 --- a/resourceschedule/ffrt/c/queue.h +++ b/resourceschedule/ffrt/c/queue.h @@ -39,7 +39,6 @@ #include "type_def.h" -typedef enum { ffrt_queue_serial, ffrt_queue_max } ffrt_queue_type_t; typedef void* ffrt_queue_t; /** @@ -122,6 +121,26 @@ FFRT_C_API void ffrt_queue_attr_set_callback(ffrt_queue_attr_t* attr, ffrt_funct */ FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue_attr_t* attr); +/** + * @brief Set the queue max concurrency. + * + * @param attr Indicates a pointer to the queue attribute. + * @param max_concurrency Indicates queue max concurrency. + * @since 12 + * @version 1.0 + */ +FFRT_C_API void ffrt_queue_attr_set_max_concurrency(ffrt_queue_attr_t* attr, const int max_concurrency); + +/** + * @brief Get the queue max concurrency. + * + * @param attr Indicates a pointer to the queue attribute. + * @return Returns the queue max concurrency. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_queue_attr_get_max_concurrency(const ffrt_queue_attr_t* attr); + /** * @brief Creates a queue. * @@ -189,4 +208,22 @@ FFRT_C_API void ffrt_queue_wait(ffrt_task_handle_t handle); */ FFRT_C_API int ffrt_queue_cancel(ffrt_task_handle_t handle); +/** + * @brief Get application main thread queue. + * + * @return Returns applicaiton main thread queue. + * @since 12 + * @version 1.0 + */ +FFRT_C_API ffrt_queue_t ffrt_get_main_queue(); + +/** + * @brief Get application worker(ArkTs) thread queue. + * + * @return Returns applicaiton worker(ArkTs) thread queue. + * @since 12 + * @version 1.0 + */ +FFRT_C_API ffrt_queue_t ffrt_get_current_queue(); + #endif // FFRT_API_C_QUEUE_H \ No newline at end of file diff --git a/resourceschedule/ffrt/c/sleep.h b/resourceschedule/ffrt/c/sleep.h index 121ab7b73..6cc905520 100644 --- a/resourceschedule/ffrt/c/sleep.h +++ b/resourceschedule/ffrt/c/sleep.h @@ -36,6 +36,7 @@ */ #ifndef FFRT_API_C_SLEEP_H #define FFRT_API_C_SLEEP_H +#include #include "type_def.h" /** diff --git a/resourceschedule/ffrt/c/task.h b/resourceschedule/ffrt/c/task.h index c6fd7f42c..fd7ad609a 100644 --- a/resourceschedule/ffrt/c/task.h +++ b/resourceschedule/ffrt/c/task.h @@ -36,6 +36,7 @@ */ #ifndef FFRT_API_C_TASK_H #define FFRT_API_C_TASK_H +#include #include "type_def.h" /** @@ -119,6 +120,26 @@ FFRT_C_API void ffrt_task_attr_set_delay(ffrt_task_attr_t* attr, uint64_t delay_ */ FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr); +/** + * @brief Sets the task priority. + * + * @param attr Indicates a pointer to the task attribute. + * @param priority Indicates the execute priority of concurrent queue task. + * @since 12 + * @version 1.0 + */ +FFRT_C_API void ffrt_task_attr_set_priority(ffrt_task_attr_t* attr, int priority); + +/** + * @brief Obtains the task priority. + * + * @param attr Indicates a pointer to the task attribute. + * @return Returns the priority of concurrent queue task. + * @since 12 + * @version 1.0 + */ +FFRT_C_API int ffrt_task_attr_get_priority(const ffrt_task_attr_t* attr); + /** * @brief Updates the QoS of this task. * @@ -130,6 +151,15 @@ FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr); */ FFRT_C_API int ffrt_this_task_update_qos(ffrt_qos_t qos); +/** + * @brief Obtains the qos of this task. + * + * @return Returns the task qos. + * @since 12 + * @version 1.0 + */ +FFRT_C_API ffrt_qos_t ffrt_this_task_get_qos(); + /** * @brief Obtains the ID of this task. * @@ -204,4 +234,11 @@ FFRT_C_API void ffrt_wait_deps(const ffrt_deps_t* deps); */ FFRT_C_API void ffrt_wait(void); +/** + * @brief Sets the thread stack size of a specified QoS level. + * + * @since 10 + * @version 1.0 + */ +FFRT_C_API ffrt_error_t ffrt_set_worker_stack_size(ffrt_qos_t qos, size_t stack_size); #endif diff --git a/resourceschedule/ffrt/c/timer.h b/resourceschedule/ffrt/c/timer.h new file mode 100644 index 000000000..f879f2b3f --- /dev/null +++ b/resourceschedule/ffrt/c/timer.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Ffrt + * @{ + * + * @brief ffrt provides APIs. + * + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * + * @since 12 + */ + + /** + * @file timer.h + * + * @brief Declares the timer interfaces in C. + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * @since 12 + * @version 1.0 + */ +#ifndef FFRT_API_C_TIMER_H +#define FFRT_API_C_TIMER_H +#include + +#include "type_def.h" + +/** + * @brief Start a timer on ffrt worker + * + * @param qos Indicates qos of the worker that runs timer. + * @param timeout Indicates the number of milliseconds that specifies timeout. + * @param data Indicates user data used in cb. + * @param cb Indicates user cb which will be executed when time out. + * @param repeat Indicates whether to repeat this timer. + * @return Returns a timer handle. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API ffrt_timer_t ffrt_timer_start(ffrt_qos_t qos, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat); + +/** + * @brief Stop a timer on ffrt worker + * + * @param qos Indicates qos of the worker that runs timer. + * @param handle Indicates the target timer handle. + * @return Returns 0 if success; + * Returns -1 otherwise. + * @since 12 + * @version 1.0 +*/ +FFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle); +#endif \ No newline at end of file diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index 1cedf23b9..c90d15188 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -36,6 +36,7 @@ */ #ifndef FFRT_API_C_TYPE_DEF_H #define FFRT_API_C_TYPE_DEF_H + #include #include @@ -45,6 +46,21 @@ #define FFRT_C_API #endif +/** + * @brief Enumerates the task priority types. + * + */ +typedef enum { + /** should be distributed at once if possible, handle time equals to send time, prior to high level */ + ffrt_task_priority_immediate = 0, + /** high priority, sorted by handle time, prior to low level. */ + ffrt_task_priority_high, + /** low priority, sorted by handle time, prior to idle level. */ + ffrt_task_priority_low, + /** lowest priority, sorted by handle time, only distribute when there is no other level inside queue. */ + ffrt_task_priority_idle, +} ffrt_task_priority_t; + /** * @brief Enumerates the task QoS types. * @@ -103,7 +119,7 @@ typedef enum { /** General task. */ ffrt_function_kind_general, /** Queue task. */ - ffrt_function_kind_queue + ffrt_function_kind_queue, } ffrt_function_kind_t; /** @@ -158,6 +174,12 @@ typedef enum { ffrt_error_inval = EINVAL } ffrt_error_t; +typedef enum { + ffrt_queue_serial = 0, + ffrt_queue_concurrent, + ffrt_queue_max +} ffrt_queue_type_t; + typedef struct { long storage; } ffrt_condattr_t; @@ -174,6 +196,13 @@ typedef struct { uint32_t storage[(ffrt_cond_storage_size + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; } ffrt_cond_t; +typedef void (*ffrt_poller_cb)(void* data, uint32_t event); + +typedef void (*ffrt_timer_cb)(void* data); + +typedef int ffrt_timer_t; + + #ifdef __cplusplus namespace ffrt { enum qos_default { @@ -184,6 +213,19 @@ enum qos_default { qos_user_initiated = ffrt_qos_user_initiated, }; using qos = int; + +enum task_priority { + immediate = ffrt_task_priority_immediate, + high = ffrt_task_priority_high, + low = ffrt_task_priority_low, + idle = ffrt_task_priority_idle, +}; + +enum queue_type { + queue_serial = ffrt_queue_serial, + queue_concurrent = ffrt_queue_concurrent, + queue_max = ffrt_queue_max, +}; } #endif #endif -- Gitee From 06e66b7341b42f5a38fb6a9338ce0329ecfe0f23 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Wed, 10 Apr 2024 11:07:53 +0800 Subject: [PATCH 02/10] update ffrt interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/type_def.h | 20 ++++++++++---------- resourceschedule/ffrt/ffrt.h | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index c90d15188..0aa502e3c 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -52,14 +52,14 @@ */ typedef enum { /** should be distributed at once if possible, handle time equals to send time, prior to high level */ - ffrt_task_priority_immediate = 0, + ffrt_queue_priority_immediate = 0, /** high priority, sorted by handle time, prior to low level. */ - ffrt_task_priority_high, + ffrt_queue_priority_high, /** low priority, sorted by handle time, prior to idle level. */ - ffrt_task_priority_low, + ffrt_queue_priority_low, /** lowest priority, sorted by handle time, only distribute when there is no other level inside queue. */ - ffrt_task_priority_idle, -} ffrt_task_priority_t; + ffrt_queue_priority_idle, +} ffrt_queue_priority_t; /** * @brief Enumerates the task QoS types. @@ -214,11 +214,11 @@ enum qos_default { }; using qos = int; -enum task_priority { - immediate = ffrt_task_priority_immediate, - high = ffrt_task_priority_high, - low = ffrt_task_priority_low, - idle = ffrt_task_priority_idle, +enum queue_priority { + immediate = ffrt_queue_priority_immediate, + high = ffrt_queue_priority_high, + low = ffrt_queue_priority_low, + idle = ffrt_queue_priority_idle, }; enum queue_type { diff --git a/resourceschedule/ffrt/ffrt.h b/resourceschedule/ffrt/ffrt.h index de48d6f52..32a4ccf54 100644 --- a/resourceschedule/ffrt/ffrt.h +++ b/resourceschedule/ffrt/ffrt.h @@ -20,11 +20,13 @@ #include "cpp/condition_variable.h" #include "cpp/sleep.h" #include "cpp/queue.h" +#include "c/timer.h" #else #include "c/task.h" #include "c/mutex.h" #include "c/condition_variable.h" #include "c/sleep.h" #include "c/queue.h" +#include "c/timer.h" #endif #endif -- Gitee From 8af8e3ba69536db3f950ce32fe7897daa5866c9a Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 09:47:49 +0800 Subject: [PATCH 03/10] update interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/loop.h | 59 +++++------ resourceschedule/ffrt/c/mutex.h | 152 ----------------------------- resourceschedule/ffrt/c/queue.h | 10 +- resourceschedule/ffrt/c/timer.h | 14 +-- resourceschedule/ffrt/c/type_def.h | 3 +- 5 files changed, 43 insertions(+), 195 deletions(-) delete mode 100644 resourceschedule/ffrt/c/mutex.h diff --git a/resourceschedule/ffrt/c/loop.h b/resourceschedule/ffrt/c/loop.h index 9a07d538e..8d3c2f375 100644 --- a/resourceschedule/ffrt/c/loop.h +++ b/resourceschedule/ffrt/c/loop.h @@ -44,66 +44,66 @@ typedef void* ffrt_loop_t; /** - * @brief Creates a loop - * + * @brief Creates a loop. + * * @param queue Indicates a queue. * @return Returns a non-null loop handle if the loop is created; - * Returns a null pointer otherwise. + returns a null pointer otherwise. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API ffrt_loop_t ffrt_loop_create(ffrt_queue_t queue); /** - * @brief Destorys a loop - * + * @brief Destroys a loop. + * * @param loop Indicates a loop handle. - * @return Returns 0 if the loop is destoryed; - * Returns -1 otherwise. + * @return returns 0 if the loop is destroyed; + returns -1 otherwise. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API int ffrt_loop_destroy(ffrt_loop_t loop); /** - * @brief start loop run - * + * @brief start loop run. + * * @param loop Indicates a loop handle. - * @return Returns -1 if loop run fail; - * Returns 0 otherwise. + * @return returns -1 if loop run fail; + returns 0 otherwise. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API int ffrt_loop_run(ffrt_loop_t loop); /** - * @brief stop loop run - * + * @brief stop loop run. + * * @param loop Indicates a loop handle. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API void ffrt_loop_stop(ffrt_loop_t loop); /** * @brief control an epoll file descriptor on ffrt loop - * + * * @param loop Indicates a loop handle. * @param op Indicates operation on the target file descriptor. * @param fd Indicates the target file descriptor on which to perform the operation. - * @param events Indicates the event type associated which the target file descriptor. + * @param events Indicates the event type associated with the target file descriptor. * @param data Indicates user data used in cb. * @param cb Indicates user cb which will be executed when the target fd is polled. * @return Returns 0 if success; - * Returns -1 otherwise. + returns -1 otherwise. * @since 12 * @version 1.0 -*/ -FFRT_C_API int ffrt_loop_epoll_ctl(ffrt_loop_t loop, int op, int fd, uint32_t events, void* data, ffrt_poller_cb cb); + */ +FFRT_C_API int ffrt_loop_epoll_ctl(ffrt_loop_t loop, int op, int fd, uint32_t events, void *data, ffrt_poller_cb cb); /** * @brief Start a timer on ffrt loop - * + * * @param loop Indicates a loop handle. * @param timeout Indicates the number of milliseconds that specifies timeout. * @param data Indicates user data used in cb. @@ -112,19 +112,20 @@ FFRT_C_API int ffrt_loop_epoll_ctl(ffrt_loop_t loop, int op, int fd, uint32_t ev * @return Returns a timer handle. * @since 12 * @version 1.0 -*/ -FFRT_C_API ffrt_timer_t ffrt_loop_timer_start(ffrt_loop_t loop, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat); + */ +FFRT_C_API ffrt_timer_t ffrt_loop_timer_start( + ffrt_loop_t loop, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat); /** * @brief Stop a target timer on ffrt loop - * + * * @param loop Indicates a loop handle. * @param handle Indicates the target timer handle. - * @return Returns 0 if success=; - * Returns -1 otherwise. + * @return Returns 0 if success; + returns -1 otherwise. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API int ffrt_loop_timer_stop(ffrt_loop_t loop, ffrt_timer_t handle); #endif \ No newline at end of file diff --git a/resourceschedule/ffrt/c/mutex.h b/resourceschedule/ffrt/c/mutex.h deleted file mode 100644 index 5bb9d2356..000000000 --- a/resourceschedule/ffrt/c/mutex.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup Ffrt - * @{ - * - * @brief ffrt provides APIs. - * - * - * @syscap SystemCapability.Resourceschedule.Ffrt.Core - * - * @since 10 - */ - -/** - * @file mutex.h - * - * @brief Declares the mutex interfaces in C. - * - * @syscap SystemCapability.Resourceschedule.Ffrt.Core - * @since 10 - * @version 1.0 - */ -#ifndef FFRT_API_C_MUTEX_H -#define FFRT_API_C_MUTEX_H -#include "type_def.h" - -/** - * @brief Initializes a mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @param attr Indicates a pointer to the mutex attribute. - * @return Returns ffrt_thrd_success if the mutex is initialized; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr); - -/** - * @brief Locks a mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is locked; - returns ffrt_thrd_error or blocks the calling thread otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_mutex_lock(ffrt_mutex_t* mutex); - -/** - * @brief Unlocks a mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is unlocked; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_mutex_unlock(ffrt_mutex_t* mutex); - -/** - * @brief Attempts to lock a mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is locked; - returns ffrt_thrd_error or ffrt_thrd_busy otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_mutex_trylock(ffrt_mutex_t* mutex); - -/** - * @brief Destroys a mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is destroyed; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_mutex_destroy(ffrt_mutex_t* mutex); - -/** - * @brief Initializes a recursive mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @param attr Indicates a pointer to the mutex attribute. - * @return Returns ffrt_thrd_success if the mutex is initialized; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_recursive_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr); - -/** - * @brief Locks a recursive mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is locked; - returns ffrt_thrd_error or blocks the calling thread otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_recursive_mutex_lock(ffrt_mutex_t* mutex); - -/** - * @brief Unlocks a recursive mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is unlocked; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_recursive_mutex_unlock(ffrt_mutex_t* mutex); - -/** - * @brief Attempts to lock a recursive mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is locked; - returns ffrt_thrd_error or ffrt_thrd_busy otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_recursive_mutex_trylock(ffrt_mutex_t* mutex); - -/** - * @brief Destroys a recursive mutex. - * - * @param mutex Indicates a pointer to the mutex. - * @return Returns ffrt_thrd_success if the mutex is destroyed; - returns ffrt_thrd_error otherwise. - * @since 10 - * @version 1.0 - */ -FFRT_C_API int ffrt_recursive_mutex_destroy(ffrt_mutex_t* mutex); -#endif diff --git a/resourceschedule/ffrt/c/queue.h b/resourceschedule/ffrt/c/queue.h index 014244372..34a3ad155 100644 --- a/resourceschedule/ffrt/c/queue.h +++ b/resourceschedule/ffrt/c/queue.h @@ -124,8 +124,8 @@ FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue /** * @brief Set the queue max concurrency. * - * @param attr Indicates a pointer to the queue attribute. - * @param max_concurrency Indicates queue max concurrency. + * @param attr Queue Property Pointer. + * @param max_concurrency queue max concurrency. * @since 12 * @version 1.0 */ @@ -134,7 +134,7 @@ FFRT_C_API void ffrt_queue_attr_set_max_concurrency(ffrt_queue_attr_t* attr, con /** * @brief Get the queue max concurrency. * - * @param attr Indicates a pointer to the queue attribute. + * @param attr Queue Property Pointer. * @return Returns the queue max concurrency. * @since 12 * @version 1.0 @@ -211,7 +211,7 @@ FFRT_C_API int ffrt_queue_cancel(ffrt_task_handle_t handle); /** * @brief Get application main thread queue. * - * @return Returns applicaiton main thread queue. + * @return Returns application main thread queue. * @since 12 * @version 1.0 */ @@ -220,7 +220,7 @@ FFRT_C_API ffrt_queue_t ffrt_get_main_queue(); /** * @brief Get application worker(ArkTs) thread queue. * - * @return Returns applicaiton worker(ArkTs) thread queue. + * @return Returns application worker(ArkTs) thread queue. * @since 12 * @version 1.0 */ diff --git a/resourceschedule/ffrt/c/timer.h b/resourceschedule/ffrt/c/timer.h index f879f2b3f..515866695 100644 --- a/resourceschedule/ffrt/c/timer.h +++ b/resourceschedule/ffrt/c/timer.h @@ -42,27 +42,27 @@ /** * @brief Start a timer on ffrt worker - * + * * @param qos Indicates qos of the worker that runs timer. * @param timeout Indicates the number of milliseconds that specifies timeout. * @param data Indicates user data used in cb. - * @param cb Indicates user cb which will be executed when time out. + * @param cb Indicates user cb which will be executed when timeout. * @param repeat Indicates whether to repeat this timer. * @return Returns a timer handle. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API ffrt_timer_t ffrt_timer_start(ffrt_qos_t qos, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat); /** - * @brief Stop a timer on ffrt worker - * + * @brief Stop a target timer on ffrt worker + * * @param qos Indicates qos of the worker that runs timer. * @param handle Indicates the target timer handle. * @return Returns 0 if success; - * Returns -1 otherwise. + returns -1 otherwise. * @since 12 * @version 1.0 -*/ + */ FFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle); #endif \ No newline at end of file diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index 0aa502e3c..9d774a9e4 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -36,7 +36,6 @@ */ #ifndef FFRT_API_C_TYPE_DEF_H #define FFRT_API_C_TYPE_DEF_H - #include #include @@ -48,7 +47,7 @@ /** * @brief Enumerates the task priority types. - * + * */ typedef enum { /** should be distributed at once if possible, handle time equals to send time, prior to high level */ -- Gitee From b2aa5e56df151004594b4cae117f2a7b0fda5357 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 10:32:15 +0800 Subject: [PATCH 04/10] update interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/task.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/resourceschedule/ffrt/c/task.h b/resourceschedule/ffrt/c/task.h index fd7ad609a..612a1702f 100644 --- a/resourceschedule/ffrt/c/task.h +++ b/resourceschedule/ffrt/c/task.h @@ -234,11 +234,4 @@ FFRT_C_API void ffrt_wait_deps(const ffrt_deps_t* deps); */ FFRT_C_API void ffrt_wait(void); -/** - * @brief Sets the thread stack size of a specified QoS level. - * - * @since 10 - * @version 1.0 - */ -FFRT_C_API ffrt_error_t ffrt_set_worker_stack_size(ffrt_qos_t qos, size_t stack_size); #endif -- Gitee From dfdfc0be3e6c5d84aaaf0cc4ffeeb11222966cb0 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 10:44:47 +0800 Subject: [PATCH 05/10] update interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/mutex.h | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 resourceschedule/ffrt/c/mutex.h diff --git a/resourceschedule/ffrt/c/mutex.h b/resourceschedule/ffrt/c/mutex.h new file mode 100644 index 000000000..b914fd316 --- /dev/null +++ b/resourceschedule/ffrt/c/mutex.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Ffrt + * @{ + * + * @brief ffrt provides APIs. + * + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * + * @since 10 + */ + +/** + * @file mutex.h + * + * @brief Declares the mutex interfaces in C. + * + * @syscap SystemCapability.Resourceschedule.Ffrt.Core + * @since 10 + * @version 1.0 + */ +#ifndef FFRT_API_C_MUTEX_H +#define FFRT_API_C_MUTEX_H +#include "type_def.h" + +/** + * @brief Initializes a mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @param attr Indicates a pointer to the mutex attribute. + * @return Returns ffrt_thrd_success if the mutex is initialized; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutex_init(ffrt_mutex_t* mutex, const ffrt_mutexattr_t* attr); + +/** + * @brief Locks a mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is locked; + returns ffrt_thrd_error or blocks the calling thread otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutex_lock(ffrt_mutex_t* mutex); + +/** + * @brief Unlocks a mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is unlocked; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutex_unlock(ffrt_mutex_t* mutex); + +/** + * @brief Attempts to lock a mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is locked; + returns ffrt_thrd_error or ffrt_thrd_busy otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutex_trylock(ffrt_mutex_t* mutex); + +/** + * @brief Destroys a mutex. + * + * @param mutex Indicates a pointer to the mutex. + * @return Returns ffrt_thrd_success if the mutex is destroyed; + returns ffrt_thrd_error otherwise. + * @since 10 + * @version 1.0 + */ +FFRT_C_API int ffrt_mutex_destroy(ffrt_mutex_t* mutex); +#endif -- Gitee From 505e328b5e3ef73c1fdd11061098e1b4e1ddf56e Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 10:51:11 +0800 Subject: [PATCH 06/10] update interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/type_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index 9d774a9e4..c003383e0 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -118,7 +118,7 @@ typedef enum { /** General task. */ ffrt_function_kind_general, /** Queue task. */ - ffrt_function_kind_queue, + ffrt_function_kind_queue } ffrt_function_kind_t; /** -- Gitee From 77cf148bb254a1c8bb32c0c33115f9c34229beda Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 17:34:35 +0800 Subject: [PATCH 07/10] update interface 17-19 Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/queue.h | 6 ++++++ resourceschedule/ffrt/c/task.h | 10 +++++----- resourceschedule/ffrt/c/type_def.h | 14 +------------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/resourceschedule/ffrt/c/queue.h b/resourceschedule/ffrt/c/queue.h index 34a3ad155..535587a24 100644 --- a/resourceschedule/ffrt/c/queue.h +++ b/resourceschedule/ffrt/c/queue.h @@ -39,6 +39,12 @@ #include "type_def.h" +typedef enum { + ffrt_queue_serial = 0, + ffrt_queue_concurrent, + ffrt_queue_max +} ffrt_queue_type_t; + typedef void* ffrt_queue_t; /** diff --git a/resourceschedule/ffrt/c/task.h b/resourceschedule/ffrt/c/task.h index 612a1702f..0ba01c05d 100644 --- a/resourceschedule/ffrt/c/task.h +++ b/resourceschedule/ffrt/c/task.h @@ -121,24 +121,24 @@ FFRT_C_API void ffrt_task_attr_set_delay(ffrt_task_attr_t* attr, uint64_t delay_ FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr); /** - * @brief Sets the task priority. + * @brief Sets the queue priority. * * @param attr Indicates a pointer to the task attribute. - * @param priority Indicates the execute priority of concurrent queue task. + * @param priority Indicates the dequeue priority of concurrent queue task. * @since 12 * @version 1.0 */ -FFRT_C_API void ffrt_task_attr_set_priority(ffrt_task_attr_t* attr, int priority); +FFRT_C_API void ffrt_task_attr_set_queue_priority(ffrt_task_attr_t* attr, ffrt_queue_priority_t priority); /** - * @brief Obtains the task priority. + * @brief Obtains the queue priority. * * @param attr Indicates a pointer to the task attribute. * @return Returns the priority of concurrent queue task. * @since 12 * @version 1.0 */ -FFRT_C_API int ffrt_task_attr_get_priority(const ffrt_task_attr_t* attr); +FFRT_C_API ffrt_queue_priority_t ffrt_task_attr_get_queue_priority(const ffrt_task_attr_t* attr); /** * @brief Updates the QoS of this task. diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index c003383e0..a17423077 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -118,7 +118,7 @@ typedef enum { /** General task. */ ffrt_function_kind_general, /** Queue task. */ - ffrt_function_kind_queue + ffrt_function_kind_queue, } ffrt_function_kind_t; /** @@ -173,12 +173,6 @@ typedef enum { ffrt_error_inval = EINVAL } ffrt_error_t; -typedef enum { - ffrt_queue_serial = 0, - ffrt_queue_concurrent, - ffrt_queue_max -} ffrt_queue_type_t; - typedef struct { long storage; } ffrt_condattr_t; @@ -219,12 +213,6 @@ enum queue_priority { low = ffrt_queue_priority_low, idle = ffrt_queue_priority_idle, }; - -enum queue_type { - queue_serial = ffrt_queue_serial, - queue_concurrent = ffrt_queue_concurrent, - queue_max = ffrt_queue_max, -}; } #endif #endif -- Gitee From 7e734de8f8868daf8c8e372709c4c09d09941778 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 19:44:56 +0800 Subject: [PATCH 08/10] update gn & json Signed-off-by: zhuguoyang --- resourceschedule/ffrt/BUILD.gn | 4 ++++ resourceschedule/ffrt/ffrt.ndk.json | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/resourceschedule/ffrt/BUILD.gn b/resourceschedule/ffrt/BUILD.gn index 9d6f81c76..89b15c3d8 100644 --- a/resourceschedule/ffrt/BUILD.gn +++ b/resourceschedule/ffrt/BUILD.gn @@ -18,10 +18,12 @@ ohos_ndk_headers("ffrt_header") { dest_dir = "$ndk_headers_out_dir/ffrt" sources = [ "c/condition_variable.h", + "c/loop.h", "c/mutex.h", "c/queue.h", "c/sleep.h", "c/task.h", + "c/timer.h", "c/type_def.h", ] } @@ -32,10 +34,12 @@ ohos_ndk_library("libffrt_ndk") { system_capability = "SystemCapability.Resourceschedule.Ffrt.Core" system_capability_headers = [ "ffrt/condition_variable.h", + "ffrt/loop.h", "ffrt/mutex.h", "ffrt/queue.h", "ffrt/sleep.h", "ffrt/task.h", + "ffrt/timer.h", "ffrt/type_def.h", ] } diff --git a/resourceschedule/ffrt/ffrt.ndk.json b/resourceschedule/ffrt/ffrt.ndk.json index 762354187..ac87d49f8 100644 --- a/resourceschedule/ffrt/ffrt.ndk.json +++ b/resourceschedule/ffrt/ffrt.ndk.json @@ -41,5 +41,21 @@ { "name": "ffrt_submit_h_base" }, { "name": "ffrt_task_handle_destroy" }, { "name": "ffrt_wait_deps" }, - { "name": "ffrt_wait" } + { "name": "ffrt_wait" }, + { "name": "ffrt_loop_create" }, + { "name": "ffrt_loop_destroy" }, + { "name": "ffrt_loop_run" }, + { "name": "ffrt_loop_stop" }, + { "name": "ffrt_loop_epoll_ctl" }, + { "name": "ffrt_loop_timer_start" }, + { "name": "ffrt_loop_timer_stop" }, + { "name": "ffrt_queue_attr_set_max_concurrency" }, + { "name": "ffrt_queue_atte_get_max_concurrency" }, + { "name": "ffrt_qet_main_queue" }, + { "name": "ffrt_get_current_queue" }, + { "name": "ffrt_task_attr_set_queue_priority" }, + { "name": "ffrt_task_attr_get_queue_priority" }, + { "name": "ffrt_this_task_get_qos" }, + { "name": "ffrt_timer_start" }, + { "name": "ffrt_timer_stop" } ] \ No newline at end of file -- Gitee From 87eb05e35aa3a0ed4c63bc2c78ef5a1eeced9a1e Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Thu, 11 Apr 2024 20:33:34 +0800 Subject: [PATCH 09/10] update gn & json Signed-off-by: zhuguoyang --- resourceschedule/ffrt/BUILD.gn | 88 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/resourceschedule/ffrt/BUILD.gn b/resourceschedule/ffrt/BUILD.gn index 89b15c3d8..8fb7e35b6 100644 --- a/resourceschedule/ffrt/BUILD.gn +++ b/resourceschedule/ffrt/BUILD.gn @@ -1,45 +1,45 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("ffrt_header") { - dest_dir = "$ndk_headers_out_dir/ffrt" - sources = [ - "c/condition_variable.h", - "c/loop.h", - "c/mutex.h", - "c/queue.h", - "c/sleep.h", - "c/task.h", - "c/timer.h", - "c/type_def.h", - ] -} - -ohos_ndk_library("libffrt_ndk") { - output_name = "ffrt" - ndk_description_file = "./ffrt.ndk.json" - system_capability = "SystemCapability.Resourceschedule.Ffrt.Core" - system_capability_headers = [ - "ffrt/condition_variable.h", - "ffrt/loop.h", - "ffrt/mutex.h", - "ffrt/queue.h", - "ffrt/sleep.h", - "ffrt/task.h", - "ffrt/timer.h", - "ffrt/type_def.h", - ] -} + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("ffrt_header") { + dest_dir = "$ndk_headers_out_dir/ffrt" + sources = [ + "c/condition_variable.h", + "c/loop.h", + "c/mutex.h", + "c/queue.h", + "c/sleep.h", + "c/task.h", + "c/timer.h", + "c/type_def.h", + ] +} + +ohos_ndk_library("libffrt_ndk") { + output_name = "ffrt" + ndk_description_file = "./ffrt.ndk.json" + system_capability = "SystemCapability.Resourceschedule.Ffrt.Core" + system_capability_headers = [ + "ffrt/condition_variable.h", + "ffrt/loop.h", + "ffrt/mutex.h", + "ffrt/queue.h", + "ffrt/sleep.h", + "ffrt/task.h", + "ffrt/timer.h", + "ffrt/type_def.h", + ] +} -- Gitee From 7940216afddbe00cdf575b2a5721ddd5bb181263 Mon Sep 17 00:00:00 2001 From: zhuguoyang Date: Fri, 12 Apr 2024 23:10:56 +0800 Subject: [PATCH 10/10] update ffrt interface Signed-off-by: zhuguoyang --- resourceschedule/ffrt/c/loop.h | 22 ---------------------- resourceschedule/ffrt/c/queue.h | 4 ++-- resourceschedule/ffrt/c/task.h | 6 +++--- resourceschedule/ffrt/c/type_def.h | 8 +------- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/resourceschedule/ffrt/c/loop.h b/resourceschedule/ffrt/c/loop.h index 8d3c2f375..f6e9d4aa6 100644 --- a/resourceschedule/ffrt/c/loop.h +++ b/resourceschedule/ffrt/c/loop.h @@ -13,28 +13,6 @@ * limitations under the License. */ -/** - * @addtogroup Ffrt - * @{ - * - * @brief ffrt provides APIs. - * - * - * @syscap SystemCapability.Resourceschedule.Ffrt.Core - * - * @since 12 - */ - -/** - * @file loop.h - * - * @brief Declares the loop interfaces in C. - * - * @syscap SystemCapability.Resourceschedule.Ffrt.Core - * @since 12 - * @version 1.0 - */ - #ifndef FFRT_API_C_LOOP_H #define FFRT_API_C_LOOP_H diff --git a/resourceschedule/ffrt/c/queue.h b/resourceschedule/ffrt/c/queue.h index 535587a24..861868185 100644 --- a/resourceschedule/ffrt/c/queue.h +++ b/resourceschedule/ffrt/c/queue.h @@ -40,7 +40,7 @@ #include "type_def.h" typedef enum { - ffrt_queue_serial = 0, + ffrt_queue_serial, ffrt_queue_concurrent, ffrt_queue_max } ffrt_queue_type_t; @@ -131,7 +131,7 @@ FFRT_C_API ffrt_function_header_t* ffrt_queue_attr_get_callback(const ffrt_queue * @brief Set the queue max concurrency. * * @param attr Queue Property Pointer. - * @param max_concurrency queue max concurrency. + * @param max_concurrency queue max_concurrency. * @since 12 * @version 1.0 */ diff --git a/resourceschedule/ffrt/c/task.h b/resourceschedule/ffrt/c/task.h index 0ba01c05d..979fe4375 100644 --- a/resourceschedule/ffrt/c/task.h +++ b/resourceschedule/ffrt/c/task.h @@ -121,17 +121,17 @@ FFRT_C_API void ffrt_task_attr_set_delay(ffrt_task_attr_t* attr, uint64_t delay_ FFRT_C_API uint64_t ffrt_task_attr_get_delay(const ffrt_task_attr_t* attr); /** - * @brief Sets the queue priority. + * @brief Sets the task priority. * * @param attr Indicates a pointer to the task attribute. - * @param priority Indicates the dequeue priority of concurrent queue task. + * @param priority Indicates the execute priority of concurrent queue task. * @since 12 * @version 1.0 */ FFRT_C_API void ffrt_task_attr_set_queue_priority(ffrt_task_attr_t* attr, ffrt_queue_priority_t priority); /** - * @brief Obtains the queue priority. + * @brief Obtains the task priority. * * @param attr Indicates a pointer to the task attribute. * @return Returns the priority of concurrent queue task. diff --git a/resourceschedule/ffrt/c/type_def.h b/resourceschedule/ffrt/c/type_def.h index a17423077..66506f85d 100644 --- a/resourceschedule/ffrt/c/type_def.h +++ b/resourceschedule/ffrt/c/type_def.h @@ -51,7 +51,7 @@ */ typedef enum { /** should be distributed at once if possible, handle time equals to send time, prior to high level */ - ffrt_queue_priority_immediate = 0, + ffrt_queue_priority_immediate, /** high priority, sorted by handle time, prior to low level. */ ffrt_queue_priority_high, /** low priority, sorted by handle time, prior to idle level. */ @@ -207,12 +207,6 @@ enum qos_default { }; using qos = int; -enum queue_priority { - immediate = ffrt_queue_priority_immediate, - high = ffrt_queue_priority_high, - low = ffrt_queue_priority_low, - idle = ffrt_queue_priority_idle, -}; } #endif #endif -- Gitee