On Tue, 12 Aug 2025 23:43:58 -0700
Dimon Zhao <dimon.z...@nebula-matrix.com> wrote:

> +static uint32_t nbl_thread_polling_task(__rte_unused void *param)
> +{
> +     struct timespec time;
> +     struct nbl_work *work;
> +     struct nbl_work *work_tmp;
> +     int i = 0;
> +
> +     time.tv_sec = 0;
> +     time.tv_nsec = 100000;
> +
> +     while (true) {
> +             i++;
> +             rte_spinlock_lock(&nbl_work_list_lock);
> +             RTE_TAILQ_FOREACH_SAFE(work, &nbl_work_list, next, work_tmp) {
> +                     if (work->no_run)
> +                             continue;
> +
> +                     if (work->run_once) {
> +                             work->handler(work->params);
> +                             TAILQ_REMOVE(&nbl_work_list, work, next);
> +                     } else {
> +                             if (i % work->tick == work->random)
> +                                     work->handler(work->params);
> +                     }
> +             }
> +
> +             rte_spinlock_unlock(&nbl_work_list_lock);
> +             nanosleep(&time, 0);
> +     }
> +
> +     return 0;

Adding another polling loop to applications is bad idea.
Please use some form of blocking operation to wake up the work handler.

Reply via email to