diff --git a/sched/hrtimer/hrtimer.h b/sched/hrtimer/hrtimer.h index 2b6386910bd..0a989c714b6 100644 --- a/sched/hrtimer/hrtimer.h +++ b/sched/hrtimer/hrtimer.h @@ -45,6 +45,12 @@ #define HRTIMER_CANCEL_SYNC_DELAY_US CONFIG_USEC_PER_TICK +/* The pending state indicates the timer belongs to the shared hrtimer queue + * and is waiting for the next hrtimer expiry. + */ + +#define hrtimer_is_pending(hrtimer) ((hrtimer)->func != NULL) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -188,26 +194,11 @@ int hrtimer_compare(FAR const hrtimer_node_t *a, RB_PROTOTYPE(hrtimer_tree_s, hrtimer_node_s, entry, hrtimer_compare); #endif -/**************************************************************************** - * Name: hrtimer_is_armed - * - * Description: - * Test whether a timer is currently armed (inserted into the container). - * - * Returned Value: - * true if armed, false otherwise. - ****************************************************************************/ - -static inline_function bool hrtimer_is_armed(FAR hrtimer_t *hrtimer) -{ - return hrtimer->func != NULL; -} - /**************************************************************************** * Name: hrtimer_remove * * Description: - * Remove a timer from the container and mark it as unarmed. + * Remove a timer from the queue and mark it as dequeued. ****************************************************************************/ static inline_function void hrtimer_remove(FAR hrtimer_t *hrtimer) @@ -218,7 +209,7 @@ static inline_function void hrtimer_remove(FAR hrtimer_t *hrtimer) list_delete_fast(&hrtimer->node.entry); #endif - /* Explicitly mark the timer as unarmed */ + /* Explicitly mark the timer as dequeued. */ hrtimer->func = NULL; } @@ -257,10 +248,10 @@ static inline_function void hrtimer_insert(FAR hrtimer_t *hrtimer) * Name: hrtimer_get_first * * Description: - * Return the earliest expiring armed timer. + * Return the earliest expiring pending timer. * * Returned Value: - * Pointer to the earliest timer, or NULL if none are armed. + * Pointer to the earliest timer, or NULL if none are pending. ****************************************************************************/ static inline_function FAR hrtimer_t *hrtimer_get_first(void) @@ -287,7 +278,7 @@ static inline_function FAR hrtimer_t *hrtimer_get_first(void) * hrtimer - Pointer to the high-resolution timer to be tested. * * Returned Value: - * true - The timer is the earliest expiring armed timer. + * true - The timer is the earliest expiring pending timer. * false - The timer is not the earliest timer. ****************************************************************************/ diff --git a/sched/hrtimer/hrtimer_cancel.c b/sched/hrtimer/hrtimer_cancel.c index 0415511bead..62833e5ccf8 100644 --- a/sched/hrtimer/hrtimer_cancel.c +++ b/sched/hrtimer/hrtimer_cancel.c @@ -91,7 +91,7 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer) ret = hrtimer_cancel_running(hrtimer); - if (hrtimer_is_armed(hrtimer)) + if (hrtimer_is_pending(hrtimer)) { hrtimer_remove(hrtimer); diff --git a/sched/hrtimer/hrtimer_start.c b/sched/hrtimer/hrtimer_start.c index 8c876ad6093..b5d9f1b21d1 100644 --- a/sched/hrtimer/hrtimer_start.c +++ b/sched/hrtimer/hrtimer_start.c @@ -75,7 +75,7 @@ int hrtimer_start_absolute(FAR hrtimer_t *hrtimer, hrtimer_entry_t func, hrtimer_cancel_running(hrtimer); - if (hrtimer_is_armed(hrtimer)) + if (hrtimer_is_pending(hrtimer)) { hrtimer_remove(hrtimer); }