• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

cQueue: 使用ANSI C 编写的 消息队列 功能函数。

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

cQueue

开源软件地址:

https://gitee.com/yorkjia/cQueue

开源软件介绍:

License

MIT License,all the people can use it for free, and thanks for uC/OS.

Usage

cQueue is message queue, is written in ANSI C in order to support as many platforms and compilers as possible.

Data Structure

cQueue using the cQueue struct data type:
/*---------------The cQueue structure ------------------------------------------------------------*/typedef struct cQueue{              void            **QMemory;  /* pointer to message queue storage area                          */                                       void            **QStart;   /* pointer to start of queue data                                 */    void            **QEnd;     /* pointer to end   of queue data                                 */    void            **QIn;      /* pointer to where next message will be inserted in the queue    */    void            **QOut;     /* pointer to where next message will be extracted from the queue */    int             QSize;      /* size of queue -- max number of entries                         */    int             QEntries;   /* current number of entries in the queue                         */} cQueue_t;

API function

/* * Description  :   create and init the queue. * * @para[in]    :   start   is a pointer to the base address of the message queue  *                          storage area,the stroage area MUST be declare as an array *                          of pointers to 'void' as follows *  *                          void *messageStroage[size] *                             * @para[in]    :   size    is the number of elements in the storage area *  * @return      :   the pointer to the new queue */cQueue_t *cQcreate(int size);/* * Description  :   delete the queue, and free the stroage area * * @para[in]    :   pq      is the pointer to the queue * * @return      :   NULL */void cQDelete(cQueue_t *pq);/* * Description  :   flush the queue, the queue is like the new create state * * @para[in]    :   pq      is the pointer to the queue * * @return      :   NULL */void cQFlush(cQueue_t *pq);/* * Description  :   receive msg from queue, if queue is empty,return NULL * * @para[in]    :   pq      is the pointer to the queue * * @para[out]   :   perr    is the pointer to error return *  * @return      : the pointer to the receive msg. */void *cQRcv(cQueue_t *pq, char *perr);/* * Description  :   send a message to the queue * * @para[in]    :   pq      is the pointer to the queue * * @para[in]    :   pmsg    is the pointer to new message to send *  * @return      :   ERR_Q_NONE      The call was successful and the message was sent *                  ERR_Q_FULL      If the queue cannot accept any more messages because it is full. */int cQPost(cQueue_t *pq, void *pmsg);/* * Description  :   send a message to the queue,the message is posted at the FRONT instead of *                  the end of the queue. Using cQPostFront() alllows you to send 'priority' *                  message. * * @para[in]    :   pq      is the pointer to the queue * * @para[in]    :   pmsg    is the pointer to new message to send *  * @return      :   ERR_Q_NONE      The call was successful and the message was sent *                  ERR_Q_FULL      If the queue cannot accept any more messages because it is full. */int cQPostFront(cQueue_t *pq, void *pmsg);

Example

the example.c show the cQueue'function.

Attention

because the type of element in the cQueue struct is (void ), so the message's type can be custom by youself.

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap