]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - fwp/lib/core/fwp_msgq.h
WIP:adding fwp_endpoint_attr
[frescor/fwp.git] / fwp / lib / core / fwp_msgq.h
1 #ifndef _FWP_MSGQ_H
2 #define _FWP_MSGQ_H
3
4 #include "fwp_conf.h"
5 #include "fwp_msgb.h"
6
7 #include <pthread.h>
8 #include <semaphore.h>
9
10 struct fwp_msgq {
11         unsigned int    nr_pending;  /**< number of messages in the queue */
12         struct fwp_msgb* queue[FWP_MSGQ_SIZE];
13         unsigned int    in;   /**< add at offset (in % size) */ 
14         unsigned int    out;  /**< extracted from offset (out % size) */ 
15         pthread_mutex_t  lock; /**< queue lock */
16         sem_t   empty_lock;     /**< semaphore to block on empty mqueue */
17         
18         /* queue reject policy */
19         /*queue_rejection_policy qr_policy;*/
20 };
21
22 void fwp_msgq_init(struct fwp_msgq *msgq);
23
24 int fwp_msgq_enqueue(struct fwp_msgq *msgq, struct fwp_msgb* msgb);
25
26 struct fwp_msgb* fwp_msgq_dequeue(struct fwp_msgq *msgq);
27 void fwp_msgq_dequeue_all(struct fwp_msgq *msgq);
28
29 /* void fwp_msgq_setpolicy */
30
31 #endif /* _FWP_MSGQ_H */