Refactoring.
[beanstalkd.git] / pq.h
blobeeba0d39670d4be66d13bc09c81bf5d813a375d9
1 /* pq.h - priority queue header */
3 #ifndef q_h
4 #define q_h
6 #include "job.h"
8 typedef struct pq {
9 unsigned int size;
10 unsigned int used;
11 job heap[];
12 } *pq;
14 /* make a fixed-size priority queue of the given size */
15 pq make_pq(unsigned int size);
17 /* return 1 if the job was inserted, else 0 */
18 int pq_give(pq q, job j);
20 /* return a job if the queue contains jobs, else NULL */
21 job pq_take(pq q);
23 /* return a job that matches the given id, else NULL */
24 /* This is O(n), so don't do it much. */
25 job pq_find(pq q, unsigned long long int id);
27 unsigned int pq_used(pq q);
29 #endif /*q_h*/