[workqueue] 增加rt_work_urgent

This commit is contained in:
Meco Man 2022-01-16 16:00:55 -05:00 committed by Bernard Xiong
parent 36cbc1fd2f
commit 8bf5a28528
2 changed files with 16 additions and 2 deletions

View File

@ -66,6 +66,7 @@ rt_err_t rt_workqueue_urgent_work(struct rt_workqueue *queue, struct rt_work *wo
#ifdef RT_USING_SYSTEM_WORKQUEUE #ifdef RT_USING_SYSTEM_WORKQUEUE
rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t ticks); rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t ticks);
rt_err_t rt_work_urgent(struct rt_work *work);
rt_err_t rt_work_cancel(struct rt_work *work); rt_err_t rt_work_cancel(struct rt_work *work);
#endif /* RT_USING_SYSTEM_WORKQUEUE */ #endif /* RT_USING_SYSTEM_WORKQUEUE */

View File

@ -7,7 +7,8 @@
* Date Author Notes * Date Author Notes
* 2017-02-27 Bernard fix the re-work issue. * 2017-02-27 Bernard fix the re-work issue.
* 2021-08-01 Meco Man remove rt_delayed_work_init() * 2021-08-01 Meco Man remove rt_delayed_work_init()
* 2021-08-14 Jackistang add comments for function interface. * 2021-08-14 Jackistang add comments for function interface
* 2022-01-16 Meco Man add rt_work_urgent()
*/ */
#include <rthw.h> #include <rthw.h>
@ -468,6 +469,18 @@ rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t ticks)
return rt_workqueue_submit_work(sys_workq, work, ticks); return rt_workqueue_submit_work(sys_workq, work, ticks);
} }
/**
* @brief Submit a work item to the system work queue without delay. This work item will be executed after the current work item.
*
* @param work is a pointer to the work item object.
*
* @return RT_EOK Success.
*/
rt_err_t rt_work_urgent(struct rt_work *work)
{
return rt_workqueue_urgent_work(sys_workq, work);
}
/** /**
* @brief Cancel a work item in the system work queue. * @brief Cancel a work item in the system work queue.
* *
@ -486,7 +499,7 @@ static int rt_work_sys_workqueue_init(void)
if (sys_workq != RT_NULL) if (sys_workq != RT_NULL)
return RT_EOK; return RT_EOK;
sys_workq = rt_workqueue_create("sys_work", RT_SYSTEM_WORKQUEUE_STACKSIZE, sys_workq = rt_workqueue_create("sys workq", RT_SYSTEM_WORKQUEUE_STACKSIZE,
RT_SYSTEM_WORKQUEUE_PRIORITY); RT_SYSTEM_WORKQUEUE_PRIORITY);
RT_ASSERT(sys_workq != RT_NULL); RT_ASSERT(sys_workq != RT_NULL);