kernel: Introduce new k_delayed_work_remaining_get API
Applications may want to know how much time is left until a delayed work gets scheduled. To prevent applications from having to track this themselves simply use the information that's already embedded as part of the timer that's part of the delayed work struct. Change-Id: I189df2f3be8b207e68b554a0cbb4f97f1a99de22 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
f99ad3f0e2
commit
c8201b2c2c
1 changed files with 16 additions and 0 deletions
|
@ -1529,6 +1529,22 @@ static inline int k_delayed_work_submit(struct k_delayed_work *work,
|
|||
return k_delayed_work_submit_to_queue(&k_sys_work_q, work, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get time remaining before a delayed work gets scheduled.
|
||||
*
|
||||
* This routine computes the (approximate) time remaining before a
|
||||
* delayed work gets executed. If the delayed work is not waiting to be
|
||||
* schedules, it returns zero.
|
||||
*
|
||||
* @param work Delayed work item.
|
||||
*
|
||||
* @return Remaining time (in milliseconds).
|
||||
*/
|
||||
static inline int32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
{
|
||||
return _timeout_remaining_get(&work->timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} end defgroup workqueue_apis
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue