Lines Matching defs:queue
32 /** SPSC lockless queue */
50 static inline void spsc_queue_init(struct spsc_queue *queue)
52 queue->head = NULL;
53 atomic_long_set(&queue->tail, (long)&queue->head);
54 atomic_set(&queue->job_count, 0);
57 static inline struct spsc_node *spsc_queue_peek(struct spsc_queue *queue)
59 return queue->head;
62 static inline int spsc_queue_count(struct spsc_queue *queue)
64 return atomic_read(&queue->job_count);
67 static inline bool spsc_queue_push(struct spsc_queue *queue, struct spsc_node *node)
75 tail = (struct spsc_node **)atomic_long_xchg(&queue->tail, (long)&node->next);
77 atomic_inc(&queue->job_count);
87 return tail == &queue->head;
91 static inline struct spsc_node *spsc_queue_pop(struct spsc_queue *queue)
98 node = READ_ONCE(queue->head);
104 WRITE_ONCE(queue->head, next);
107 /* slowpath for the last element in the queue */
109 if (atomic_long_cmpxchg(&queue->tail,
110 (long)&node->next, (long) &queue->head) != (long)&node->next) {
114 } while (unlikely(!(queue->head = READ_ONCE(node->next))));
118 atomic_dec(&queue->job_count);