]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - fwp/lib/core/fwp_msgq.h
Added support for contract negotiation
[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 /**
11  * Message queue structure
12  *
13  */
14 struct fwp_msgq {
15         unsigned int    nr_pending;  /**< number of messages in the queue */
16         struct fwp_msgb* queue[FWP_MSGQ_SIZE];
17         unsigned int    in;   /**< add at offset (in % size) */ 
18         unsigned int    out;  /**< extracted from offset (out % size) */ 
19         pthread_mutex_t  lock; /**< queue lock */
20         sem_t   empty_lock;     /**< semaphore to block on empty mqueue */
21         
22         /* queue reject policy */
23         /*queue_rejection_policy qr_policy;*/
24 };
25
26 void fwp_msgq_init(struct fwp_msgq *msgq);
27
28 int fwp_msgq_enqueue(struct fwp_msgq *msgq, struct fwp_msgb* msgb);
29
30 struct fwp_msgb* fwp_msgq_dequeue(struct fwp_msgq *msgq);
31 void fwp_msgq_dequeue_all(struct fwp_msgq *msgq);
32
33 /* void fwp_msgq_setpolicy */
34
35 #endif /* _FWP_MSGQ_H */