MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_workqueue_cancel_work_sync

Function rt_workqueue_cancel_work_sync

components/drivers/ipc/workqueue.c:360–377  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

358 * @return RT_EOK Success.
359 */
360rt_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.

Callers 3

cancle_work_test04Function · 0.85
repeat_work_test03Function · 0.85
aio_cancelFunction · 0.85

Calls 2

rt_sem_takeFunction · 0.85
_workqueue_cancel_workFunction · 0.85

Tested by

no test coverage detected