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