* @brief Cancel a work item in the work queue. If the work item is executing, this function will block until it is done. * * @param queue is a pointer to the workqueue object. * * @param work is a pointer to the work item object. * * @return RT_EOK Success. */
| 358 | * @return RT_EOK Success. |
| 359 | */ |
| 360 | rt_err_t rt_workqueue_cancel_work_sync(struct rt_workqueue *queue, struct rt_work *work) |
| 361 | { |
| 362 | RT_ASSERT(queue != RT_NULL); |
| 363 | RT_ASSERT(work != RT_NULL); |
| 364 | |
| 365 | if (queue->work_current == work) /* it's current work in the queue */ |
| 366 | { |
| 367 | /* wait for work completion */ |
| 368 | rt_sem_take(&(queue->sem), RT_WAITING_FOREVER); |
| 369 | /* Note that because work items are automatically deleted after execution, they do not need to be deleted again */ |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | _workqueue_cancel_work(queue, work); |
| 374 | } |
| 375 | |
| 376 | return RT_EOK; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * @brief This function will cancel all work items in work queue. |
no test coverage detected