| 68 | ****************************************************************************/ |
| 69 | |
| 70 | int work_queue_next_wq(FAR struct kwork_wqueue_s *wqueue, |
| 71 | FAR struct work_s *work, worker_t worker, |
| 72 | FAR void *arg, clock_t delay) |
| 73 | { |
| 74 | irqstate_t flags; |
| 75 | |
| 76 | if (wqueue == NULL || work == NULL || worker == NULL || |
| 77 | delay > WDOG_MAX_DELAY) |
| 78 | { |
| 79 | return -EINVAL; |
| 80 | } |
| 81 | |
| 82 | /* Initialize the work structure. */ |
| 83 | |
| 84 | work->worker = worker; /* Work callback. non-NULL means queued */ |
| 85 | work->arg = arg; /* Callback argument */ |
| 86 | work->qtime += delay; /* Expected time based on last expiration time */ |
| 87 | |
| 88 | flags = spin_lock_irqsave(&wqueue->lock); |
| 89 | |
| 90 | if (delay) |
| 91 | { |
| 92 | /* Insert to the pending list of the wqueue. */ |
| 93 | |
| 94 | if (work_insert_pending(wqueue, work)) |
| 95 | { |
| 96 | /* Start the timer if the work is the earliest expired work. */ |
| 97 | |
| 98 | wd_start_abstick(&wqueue->timer, work->qtime, |
| 99 | work_timer_expired, (wdparm_t)wqueue); |
| 100 | } |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | /* Insert to the expired list of the wqueue. */ |
| 105 | |
| 106 | list_add_tail(&wqueue->expired, &work->node); |
| 107 | } |
| 108 | |
| 109 | spin_unlock_irqrestore(&wqueue->lock, flags); |
| 110 | |
| 111 | if (!delay) |
| 112 | { |
| 113 | /* Immediately wake up the worker thread. */ |
| 114 | |
| 115 | nxsem_post(&wqueue->sem); |
| 116 | } |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | int work_queue_next(int qid, FAR struct work_s *work, worker_t worker, |
| 122 | FAR void *arg, clock_t delay) |
no test coverage detected