Swoole源码学习记录(七)——MsgQueue

本文介绍了Swoole 1.7.5-beta版本中的MsgQueue实现,包括消息队列的结构体定义、创建过程及操作函数。重点讲解了swQueueMsg_create函数,解析了msgget参数的意义。同时提到了消息的写入、读取和释放操作,并简述了作者因个人事务暂停更新的情况。
摘要由CSDN通过智能技术生成

Swoole版本:1.7.5-beta

版本更换通知:从第七章开始,我把分析的源码版本升到了1.7.5-beta。在已经分析过的代码中存在了一些变动,但没有到会影响理解的地步,所以再次不再更新前面的章节。如果确认前面的章节有重大变更需要重新分析的,我会给出声明。

 

Swoole内部封装了Linux提供的msg queue用于提供消息队列的操作。消息队列的声明在swoole.h文件的360 – 378 行。声明如下:

typedef struct _swQueue_Data
{
         long mtype;                            /* type of received/sent message*/
         char mdata[sizeof(swEventData)];  /* text ofthe message */
} swQueue_data;
 
typedef struct _swQueue
{
         void *object;
         int blocking;
         int (*in)(struct _swQueue *, swQueue_data *in, int data_length);
         int (*out)(struct _swQueue *, swQueue_data *out, int buffer_length);
         void (*free)(struct _swQueue *);
         int (*notify)(struct _swQueue *);
         int (*wait)(struct _swQueue *);
} swQueue;
 
int swQueueMsg_create(swQueue *p, int wait,int msg_key, long type);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值