Commit c8201b2c authored by Johan Hedberg's avatar Johan Hedberg Committed by Benjamin Walsh
Browse files

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: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent f99ad3f0
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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
 */