forked from beanstalkd/beanstalkd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pq.h
27 lines (19 loc) · 568 Bytes
/
pq.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* pq.h - priority queue header */
#ifndef q_h
#define q_h
#include "job.h"
typedef struct pq {
unsigned int size;
unsigned int used;
job heap[];
} *pq;
/* make a fixed-size priority queue of the given size */
pq make_pq(unsigned int size);
/* return 1 if the job was inserted, else 0 */
int pq_give(pq q, job j);
/* return a job if the queue contains jobs, else NULL */
job pq_take(pq q);
/* return a job that matches the given id, else NULL */
/* This is O(n), so don't do it much. */
job pq_find(pq q, unsigned long long int id);
#endif /*q_h*/