Fix-Point commented on code in PR #16231:
URL: https://github.com/apache/nuttx/pull/16231#discussion_r2074628950


##########
include/nuttx/wqueue.h:
##########
@@ -249,19 +249,11 @@ typedef CODE void (*worker_t)(FAR void *arg);
 
 struct work_s
 {
-  union
-  {
-    struct
-    {
-      struct list_node node;     /* Implements a double linked list */
-      clock_t qtime;             /* Time work queued */
-    } s;
-    struct wdog_s timer;         /* Delay expiry timer */
-    struct wdog_period_s ptimer; /* Period expiry timer */
-  } u;
-  worker_t  worker;              /* Work callback */
-  FAR void *arg;                 /* Callback argument */
-  FAR struct kwork_wqueue_s *wq; /* Work queue */
+  struct list_node  node;   /* Implements a double linked list */

Review Comment:
   Done.



##########
sched/wqueue/wqueue.h:
##########
@@ -159,6 +148,65 @@ static inline_function FAR struct kwork_wqueue_s 
*work_qid2wq(int qid)
     }
 }
 
+/****************************************************************************
+ * Name: work_insert_pending
+ *
+ * Description:
+ *   Internal public function to insert the work to the workqueue.
+ *   Require wqueue != NULL and work != NULL.
+ *
+ * Input Parameters:
+ *   wqueue - The work queue.
+ *   work   - The work to be inserted.
+ *
+ * Returned Value:
+ *   Return whether the work is inserted at the head of the pending queue.
+ *
+ ****************************************************************************/
+
+static inline_function
+bool work_insert_pending(FAR struct kwork_wqueue_s *wqueue,
+                         FAR struct work_s         *work)
+{
+  struct work_s *curr;
+
+  DEBUGASSERT(wqueue != NULL && work != NULL);
+
+  /* Insert the work into the wait queue sorted by the expired time. */
+
+  list_for_every_entry(&wqueue->pending, curr, struct work_s, node)
+    {
+      if (!clock_compare(curr->qtime, work->qtime))
+        {
+          break;
+        }
+    }
+
+  /* After the insertion, we do not violate the invariant that
+   * the wait queue is sorted by the expired time. Because
+   * curr->qtime > work_qtime.

Review Comment:
   Done.



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to