walnux/libs/libc/wqueue
ouyangxiangzhen 900b1c19dd wqueue: improve the robustness of the work
struct work_s
{
  union
  {
    struct
    {
      struct dq_entry_s dq;      /* 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 */
};

work_cancel() should determine whether the current work is
in the timer or has already entered the queue.
This judgment is indispensable because the structure is a union.
Whether it is interpreted as a timer or as a dq needs to be determined.

But this judgment seriously depends on the order of struct wdog_s and
struct dq_entry_s, once someone change the order of any, there is a bug.
So we decide remove the union, to improve the robustness.

For the work_s structure size will grow bigger, then we will provide a
another optimization patch

Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-05-07 02:02:10 +08:00
..
CMakeLists.txt cmake:refine nuttx cmake build system fix CMake build missing part 2024-10-13 02:25:06 +08:00
Kconfig Rename LIB_ to LIBC_ for all libc Kconfig 2021-08-05 19:45:24 +02:00
Make.defs libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
work_cancel.c wqueue: improve the robustness of the work 2025-05-07 02:02:10 +08:00
work_queue.c wqueue: improve the robustness of the work 2025-05-07 02:02:10 +08:00
work_usrthread.c wqueue: improve the robustness of the work 2025-05-07 02:02:10 +08:00
wqueue.h libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00