diff options
author | Uros Majstorovic <majstor@majstor.org> | 2018-01-11 21:28:22 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2018-01-11 21:28:22 +0100 |
commit | 0d0e9facfcea3cf96da3b63285865182fdd5477e (patch) | |
tree | cca42e7aab184cad981c794073a4376aa2616193 /code/ecp/msgq.h | |
parent | 05e11f491b84a110b9ca08612df370b91e9bdcbc (diff) |
refatoring dirs
Diffstat (limited to 'code/ecp/msgq.h')
-rw-r--r-- | code/ecp/msgq.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/code/ecp/msgq.h b/code/ecp/msgq.h new file mode 100644 index 0000000..41e819b --- /dev/null +++ b/code/ecp/msgq.h @@ -0,0 +1,26 @@ +#ifdef ECP_WITH_MSGQ + +#include <pthread.h> +#include <string.h> + +#define ECP_MSGQ_MAX_MSG 32 +#define ECP_MSGQ_ERR_MAX_MSG -110 + +typedef struct ECPConnMsgQ { + unsigned short idx_w[ECP_MAX_MTYPE]; + unsigned short idx_r[ECP_MAX_MTYPE]; + ecp_seq_t seq_start; + ecp_seq_t seq_max; + ecp_seq_t seq_msg[ECP_MAX_MTYPE][ECP_MSGQ_MAX_MSG]; + pthread_cond_t cond[ECP_MAX_MTYPE]; + pthread_mutex_t mutex; +} ECPConnMsgQ; + +int ecp_conn_msgq_create(ECPConnMsgQ *msgq); +void ecp_conn_msgq_destroy(ECPConnMsgQ *msgq); +int ecp_conn_msgq_start(ECPConnMsgQ *msgq, ecp_seq_t seq); + +int ecp_conn_msgq_push(struct ECPConnection *conn, ecp_seq_t seq, unsigned char mtype); +ssize_t ecp_conn_msgq_pop(struct ECPConnection *conn, unsigned char mtype, unsigned char *msg, size_t msg_size, ecp_cts_t timeout); + +#endif /* ECP_WITH_MSGQ */
\ No newline at end of file |