Lines Matching refs:queue
30 /** SPSC lockless queue */
48 static inline void spsc_queue_init(struct spsc_queue *queue)
50 queue->head = NULL;
51 atomic_long_set(&queue->tail, (long)&queue->head);
52 atomic_set(&queue->job_count, 0);
55 static inline struct spsc_node *spsc_queue_peek(struct spsc_queue *queue)
57 return queue->head;
60 static inline int spsc_queue_count(struct spsc_queue *queue)
62 return atomic_read(&queue->job_count);
65 static inline bool spsc_queue_push(struct spsc_queue *queue, struct spsc_node *node)
73 tail = (struct spsc_node **)atomic_long_xchg(&queue->tail, (long)&node->next);
75 atomic_inc(&queue->job_count);
85 return tail == &queue->head;
89 static inline struct spsc_node *spsc_queue_pop(struct spsc_queue *queue)
96 node = READ_ONCE(queue->head);
102 WRITE_ONCE(queue->head, next);
105 /* slowpath for the last element in the queue */
107 if (atomic_long_cmpxchg(&queue->tail,
108 (long)&node->next, (long) &queue->head) != (long)&node->next) {
112 } while (unlikely(!(queue->head = READ_ONCE(node->next))));
116 atomic_dec(&queue->job_count);