Lines Matching defs:waitq

15  * vdo_waitq_enqueue_waiter() - Add a waiter to the tail end of a waitq.
16 * @waitq: The vdo_wait_queue to which to add the waiter.
17 * @waiter: The waiter to add to the waitq.
19 * The waiter must not already be waiting in a waitq.
21 void vdo_waitq_enqueue_waiter(struct vdo_wait_queue *waitq, struct vdo_waiter *waiter)
25 if (waitq->last_waiter == NULL) {
27 * The waitq is empty, so form the initial circular list by self-linking the
32 /* Splice the new waiter in at the end of the waitq. */
33 waiter->next_waiter = waitq->last_waiter->next_waiter;
34 waitq->last_waiter->next_waiter = waiter;
38 waitq->last_waiter = waiter;
39 waitq->length += 1;
43 * vdo_waitq_transfer_all_waiters() - Transfer all waiters from one waitq to
44 * a second waitq, emptying the first waitq.
45 * @from_waitq: The waitq containing the waiters to move.
46 * @to_waitq: The waitq that will receive the waiters from the first waitq.
51 /* If the source waitq is empty, there's nothing to do. */
73 * vdo_waitq_notify_all_waiters() - Notify all the entries waiting in a waitq.
74 * @waitq: The vdo_wait_queue containing the waiters to notify.
79 * Notifies all the entries waiting in a waitq to continue execution by invoking a callback
80 * function on each of them in turn. The waitq is copied and emptied before invoking any callbacks,
81 * and only the waiters that were in the waitq at the start of the call will be notified.
83 void vdo_waitq_notify_all_waiters(struct vdo_wait_queue *waitq,
87 * Copy and empty the waitq first, avoiding the possibility of an infinite
88 * loop if entries are returned to the waitq by the callback function.
93 vdo_waitq_transfer_all_waiters(waitq, &waiters);
95 /* Drain the copied waitq, invoking the callback on every entry. */
101 * vdo_waitq_get_first_waiter() - Return the waiter that is at the head end of a waitq.
102 * @waitq: The vdo_wait_queue from which to get the first waiter.
104 * Return: The first (oldest) waiter in the waitq, or NULL if the waitq is empty.
106 struct vdo_waiter *vdo_waitq_get_first_waiter(const struct vdo_wait_queue *waitq)
108 struct vdo_waiter *last_waiter = waitq->last_waiter;
115 /* The waitq is circular, so the last entry links to the head of the waitq. */
122 * @waitq: The vdo_wait_queue to process.
127 void vdo_waitq_dequeue_matching_waiters(struct vdo_wait_queue *waitq,
135 vdo_waitq_transfer_all_waiters(waitq, &iteration_waitq);
141 matched_waitq : waitq), waiter);
146 * vdo_waitq_dequeue_waiter() - Remove the first (oldest) waiter from a waitq.
147 * @waitq: The vdo_wait_queue from which to remove the first entry.
152 * Return: The first (oldest) waiter in the waitq, or NULL if the waitq is empty.
154 struct vdo_waiter *vdo_waitq_dequeue_waiter(struct vdo_wait_queue *waitq)
156 struct vdo_waiter *first_waiter = vdo_waitq_get_first_waiter(waitq);
157 struct vdo_waiter *last_waiter = waitq->last_waiter;
163 /* The waitq has a single entry, so empty it by nulling the tail. */
164 waitq->last_waiter = NULL;
167 * The waitq has multiple waiters, so splice the first waiter out
168 * of the circular waitq.
173 /* The waiter is no longer in a waitq. */
175 waitq->length -= 1;
181 * vdo_waitq_notify_next_waiter() - Notify the next entry waiting in a waitq.
182 * @waitq: The vdo_wait_queue containing the waiter to notify.
187 * Notifies the next entry waiting in a waitq to continue execution by invoking a callback function
188 * on it after removing it from the waitq.
190 * Return: true if there was a waiter in the waitq.
192 bool vdo_waitq_notify_next_waiter(struct vdo_wait_queue *waitq,
195 struct vdo_waiter *waiter = vdo_waitq_dequeue_waiter(waitq);