Lines Matching +full:- +full:q

2  * Copyright (c) 2010-2011 Dmitry Vyukov
5 * SPDX-License-Identifier: Apache-2.0
30 * @brief A wait-free intrusive multi producer single consumer (MPSC) queue using
31 * a singly linked list. Ordering is First-In-First-Out.
33 * Based on the well known and widely used wait-free MPSC queue described by
111 * @param q Queue to initialize or reset
113 static inline void mpsc_init(struct mpsc *q) in mpsc_init() argument
115 mpsc_ptr_set(q->head, &q->stub); in mpsc_init()
116 q->tail = &q->stub; in mpsc_init()
117 mpsc_ptr_set(q->stub.next, NULL); in mpsc_init()
123 * @param q Queue to push the node to
126 static ALWAYS_INLINE void mpsc_push(struct mpsc *q, struct mpsc_node *n) in mpsc_push() argument
131 mpsc_ptr_set(n->next, NULL); in mpsc_push()
134 prev = (struct mpsc_node *)mpsc_ptr_set_get(q->head, n); in mpsc_push()
135 mpsc_ptr_set(prev->next, n); in mpsc_push()
145 static inline struct mpsc_node *mpsc_pop(struct mpsc *q) in mpsc_pop() argument
148 struct mpsc_node *tail = q->tail; in mpsc_pop()
149 struct mpsc_node *next = (struct mpsc_node *)mpsc_ptr_get(tail->next); in mpsc_pop()
152 if (tail == &q->stub) { in mpsc_pop()
157 q->tail = next; in mpsc_pop()
159 next = (struct mpsc_node *)mpsc_ptr_get(next->next); in mpsc_pop()
162 /* If next is non-NULL then a valid node is found, return it */ in mpsc_pop()
164 q->tail = next; in mpsc_pop()
168 head = (struct mpsc_node *)mpsc_ptr_get(q->head); in mpsc_pop()
177 mpsc_push(q, &q->stub); in mpsc_pop()
179 next = (struct mpsc_node *)mpsc_ptr_get(tail->next); in mpsc_pop()
182 q->tail = next; in mpsc_pop()