xiaoxiang781216 commented on code in PR #17784:
URL: https://github.com/apache/nuttx/pull/17784#discussion_r2667058017


##########
include/nuttx/hrtimer.h:
##########
@@ -65,8 +65,8 @@ typedef struct hrtimer_node_s hrtimer_node_t;
  * timer context and must not block.
  */
 
-typedef CODE uint64_t
-(*hrtimer_cb)(FAR hrtimer_t *hrtimer, uint64_t expired);
+typedef CODE uint64_t (*hrtimer_entry_t)(FAR const hrtimer_t *hrtimer,

Review Comment:
   why change the callback type name



##########
sched/hrtimer/hrtimer_cancel.c:
##########
@@ -129,11 +129,13 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
   if (hrtimer_is_armed(hrtimer))
     {
       hrtimer_remove(hrtimer);
-    }
 
-  /* Mark timer as cancelled */
+      /* Mark timer as cancelled */
+
+      hrtimer->func = NULL;
+    }
 
-  hrtimer->expired = UINT64_MAX;
+  hrtimer->expired++;

Review Comment:
   but should we check func in hrtimer_process



##########
sched/hrtimer/hrtimer.h:
##########
@@ -196,10 +196,7 @@ RB_PROTOTYPE(hrtimer_tree_s, hrtimer_node_s, entry, 
hrtimer_compare);
 
 static inline_function bool hrtimer_is_armed(FAR hrtimer_t *hrtimer)
 {
-  /* RB-tree root has NULL parent, so root must be checked explicitly */
-
-  return RB_PARENT(&hrtimer->node, entry) != NULL ||
-         RB_ROOT(&g_hrtimer_tree) == &hrtimer->node;
+  return hrtimer->func != NULL;

Review Comment:
   but what's problem with the previous check



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to