Put the objects before the libraries when building
[nmdb.git] / nmdb / queue.h
blob17a4ec06b0b345b2a0d9a66058f50ac80600ff1d
2 #ifndef _QUEUE_H
3 #define _QUEUE_H
5 #include <pthread.h> /* for mutexes */
6 #include <stdint.h> /* for uint32_t */
7 #include "req.h" /* for req_info */
8 #include "sparse.h"
10 struct queue {
11 pthread_mutex_t lock;
12 pthread_cond_t cond;
14 size_t size;
15 struct queue_entry *top, *bottom;
18 struct queue_entry {
19 uint32_t operation;
20 struct req_info *req;
22 unsigned char *key;
23 unsigned char *val;
24 unsigned char *newval;
25 size_t ksize;
26 size_t vsize;
27 size_t nvsize;
29 struct queue_entry *prev;
30 /* A pointer to the next element on the list is actually not
31 * necessary, because it's not needed for put and get.
36 struct queue *queue_create();
37 void queue_free(struct queue *q);
39 struct queue_entry *queue_entry_create();
40 void queue_entry_free(struct queue_entry *e);
42 void queue_lock(struct queue *q)
43 __acquires(q->lock);
44 void queue_unlock(struct queue *q)
45 __releases(q->lock);
46 void queue_signal(struct queue *q);
47 int queue_timedwait(struct queue *q, struct timespec *ts)
48 __with_lock_acquired(q->lock);
50 void queue_put(struct queue *q, struct queue_entry *e)
51 __with_lock_acquired(q->lock);
52 struct queue_entry *queue_get(struct queue *q)
53 __with_lock_acquired(q->lock);
54 int queue_isempty(struct queue *q)
55 __with_lock_acquired(q->lock);
57 #endif