14 static inline struct io_u *io_u_qpop(struct io_u_queue *q)
17 const unsigned int next = --q->nr;
18 struct io_u *io_u = q->io_us[next];
20 q->io_us[next] = NULL;
27 static inline void io_u_qpush(struct io_u_queue *q, struct io_u *io_u)
30 q->io_us[q->nr++] = io_u;
37 static inline int io_u_qempty(const struct io_u_queue *q)
42 #define io_u_qiter(q, io_u, i) \
43 for (i = 0; i < (q)->nr && (io_u = (q)->io_us[i]); i++)
45 int io_u_qinit(struct io_u_queue *q, unsigned int nr);
46 void io_u_qexit(struct io_u_queue *q);
55 int io_u_rinit(struct io_u_ring *ring, unsigned int nr);
56 void io_u_rexit(struct io_u_ring *ring);
58 static inline void io_u_rpush(struct io_u_ring *r, struct io_u *io_u)
60 if (r->head + 1 != r->tail) {
61 r->ring[r->head] = io_u;
62 r->head = (r->head + 1) & (r->max - 1);
69 static inline struct io_u *io_u_rpop(struct io_u_ring *r)
71 if (r->head != r->tail) {
72 struct io_u *io_u = r->ring[r->tail];
74 r->tail = (r->tail + 1) & (r->max - 1);
81 static inline int io_u_rempty(struct io_u_ring *ring)
83 return ring->head == ring->tail;