diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-08-14 19:56:24 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-08-14 19:56:24 +0200 |
commit | 38e2385f5846860916f8880d818b3b024b8c7dd9 (patch) | |
tree | 7bb01d9c38df29b49bf87c50317ec67c61c6e2a7 /code/core/msgq.h | |
parent | db44820eb01106f7780c7126e53885e8b34c8aea (diff) |
msgq implementation
Diffstat (limited to 'code/core/msgq.h')
-rw-r--r-- | code/core/msgq.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/code/core/msgq.h b/code/core/msgq.h index 9d16f63..54319e0 100644 --- a/code/core/msgq.h +++ b/code/core/msgq.h @@ -3,30 +3,21 @@ #include <pthread.h> #include <string.h> -#define ECP_MAX_CONN_MSG 8 +#define ECP_MAX_CONN_MSG 32 #define ECP_ERR_MAX_CONN_MSG -100 -struct ECPConnection; - -typedef struct ECPMessage { - unsigned char msg[ECP_MAX_MSG]; - ssize_t size; -} ECPMessage; - typedef struct ECPConnMsgQ { - unsigned short empty_idx; - unsigned short occupied[ECP_MAX_CONN_MSG]; - unsigned short w_idx[ECP_MAX_MTYPE]; - unsigned short r_idx[ECP_MAX_MTYPE]; - unsigned short msg_idx[ECP_MAX_MTYPE][ECP_MAX_CONN_MSG+1]; - ECPMessage msg[ECP_MAX_CONN_MSG]; - pthread_mutex_t mutex; + unsigned short idx_w[ECP_MAX_MTYPE]; + unsigned short idx_r[ECP_MAX_MTYPE]; + ecp_seq_t seq_msg[ECP_MAX_MTYPE][ECP_MAX_CONN_MSG]; pthread_cond_t cond[ECP_MAX_MTYPE]; + pthread_mutex_t mutex; } ECPConnMsgQ; int ecp_conn_msgq_create(struct ECPConnection *conn); void ecp_conn_msgq_destroy(struct ECPConnection *conn); -ssize_t ecp_conn_msgq_push(struct ECPConnection *conn, unsigned char *msg, size_t msg_size); + +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, unsigned int timeout); #endif /* ECP_WITH_PTHREAD */
\ No newline at end of file |