kernel: Add k_delayed_work_pending to check if work has been submitted
Add k_delayed_work_pending similar to k_work_pending to check if the delayed work item has been submitted but not yet completed. This would compliment the API since using k_work_pending or k_delayed_work_remaining_get is not enough to check this condition. This is because the timeout could have run out, but the timeout handler not yet processed and put the work into the workqueue. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
ed642dcd24
commit
ea9590448d
3 changed files with 57 additions and 0 deletions
|
@ -3233,6 +3233,25 @@ static inline bool k_work_pending(struct k_work *work)
|
|||
return atomic_test_bit(work->flags, K_WORK_STATE_PENDING);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a delayed work item is pending.
|
||||
*
|
||||
* This routine indicates if the work item @a work is pending in a workqueue's
|
||||
* queue or waiting for the delay timeout.
|
||||
*
|
||||
* @note Checking if the delayed work is pending gives no guarantee that the
|
||||
* work will still be pending when this information is used. It is up to
|
||||
* the caller to make sure that this information is used in a safe manner.
|
||||
*
|
||||
* @note Can be called by ISRs.
|
||||
*
|
||||
* @param work Address of delayed work item.
|
||||
*
|
||||
* @return true if work item is waiting for the delay to expire or pending on a
|
||||
* work queue, or false if it is not pending.
|
||||
*/
|
||||
bool k_delayed_work_pending(struct k_delayed_work *work);
|
||||
|
||||
/**
|
||||
* @brief Start a workqueue.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue