2019-12-01 01:02:08 -07:00
|
|
|
#ifndef __MSG_QUEUE_H_INCLUDED
|
|
|
|
#define __MSG_QUEUE_H_INCLUDED
|
|
|
|
|
2019-12-07 13:07:59 -07:00
|
|
|
#include <pthread.h>
|
2019-12-01 01:02:08 -07:00
|
|
|
#include "wintype.h"
|
|
|
|
#include "msg.h"
|
|
|
|
|
2019-12-07 13:07:59 -07:00
|
|
|
/* internal structure of a message queue */
|
2019-12-01 01:02:08 -07:00
|
|
|
typedef struct tagMSG_QUEUE {
|
2019-12-07 13:07:59 -07:00
|
|
|
struct tagMSG_QUEUE *next; /* allow us to be in a singly-linked list */
|
|
|
|
PMSG startbound; /* start boundary for message buffer */
|
|
|
|
PMSG endbound; /* end boundary for message buffer */
|
|
|
|
PMSG head; /* head pointer of message queue */
|
|
|
|
PMSG tail; /* tail pointer of message queue */
|
|
|
|
UINT32 nentries; /* number of entries possible in message buffer */
|
|
|
|
pthread_mutex_t mutex; /* controls access to queue from multiple threads */
|
|
|
|
MSG messagestore[0]; /* message buffer */
|
2019-12-01 01:02:08 -07:00
|
|
|
} MSG_QUEUE, *PMSG_QUEUE;
|
|
|
|
|
2019-12-07 13:07:59 -07:00
|
|
|
/* flags to Mq_peek */
|
|
|
|
#define PEEK_REMOVE 0x0001 /* remove message if found */
|
|
|
|
#define PEEK_NOREMOVE 0x0000 /* do not remove message if found */
|
2019-12-01 01:02:08 -07:00
|
|
|
|
2019-12-05 18:21:37 -07:00
|
|
|
extern PMSG_QUEUE Mq_alloc(UINT32 nentries);
|
2019-12-01 15:43:05 -07:00
|
|
|
extern void Mq_destroy(PMSG_QUEUE queue);
|
2019-12-05 18:21:37 -07:00
|
|
|
extern void Mq_post(PMSG_QUEUE queue, HANDLE target, UINT32 message, const UINT_PTR *attrs, int nattrs);
|
2019-12-07 00:46:27 -07:00
|
|
|
extern void Mq_post2(PMSG_QUEUE queue, HANDLE target, UINT32 message, UINT_PTR attr1, UINT_PTR attr2);
|
2019-12-05 18:21:37 -07:00
|
|
|
extern BOOL Mq_peek(PMSG_QUEUE queue, PMSG msg, UINT32 flags);
|
2019-12-09 11:18:24 -07:00
|
|
|
extern BOOL Mq_is_empty(PMSG_QUEUE queue);
|
2019-12-01 01:02:08 -07:00
|
|
|
|
2019-12-07 00:46:27 -07:00
|
|
|
#define Mq_post0(q, tgt, msg) Mq_post2(q, tgt, msg, 0, 0)
|
|
|
|
#define Mq_post1(q, tgt, msg, attr) Mq_post2(q, tgt, msg, attr, 0)
|
|
|
|
|
2019-12-01 01:02:08 -07:00
|
|
|
#endif /* __MSG_QUEUE_H_INCLUDED */
|