sched/hrtimer: Add callback pointer in hrtimer_start.

The hrtimer is designed to replace the wdog timer in future, so it
should have the callback function in its API. The evaluation results showed there is no any
performance degradation since the CPU pipeline can hide the latency.
This commit also decoupled the rb-tree implementation with the pending
state checking.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2026-01-07 15:17:56 +08:00
committed by GUIDINGLI
parent cd6a978ba9
commit a518c28add
4 changed files with 10 additions and 13 deletions
+3 -7
View File
@@ -118,12 +118,7 @@ extern "C"
* None
****************************************************************************/
static inline_function
void hrtimer_init(FAR hrtimer_t *hrtimer, hrtimer_cb func)
{
memset(hrtimer, 0, sizeof(hrtimer_t));
hrtimer->func = func;
}
#define hrtimer_init(hrtimer) memset(hrtimer, 0, sizeof(hrtimer_t))
/****************************************************************************
* Name: hrtimer_cancel
@@ -184,6 +179,7 @@ int hrtimer_cancel_sync(FAR hrtimer_t *hrtimer);
*
* Input Parameters:
* hrtimer - Timer instance to start
* func - Expiration callback function
* expired - Expiration time in nanoseconds
* mode - HRTIMER_MODE_ABS or HRTIMER_MODE_REL
*
@@ -191,7 +187,7 @@ int hrtimer_cancel_sync(FAR hrtimer_t *hrtimer);
* OK on success; a negated errno value on failure.
****************************************************************************/
int hrtimer_start(FAR hrtimer_t *hrtimer,
int hrtimer_start(FAR hrtimer_t *hrtimer, hrtimer_entry_t func,
uint64_t expired,
enum hrtimer_mode_e mode);