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);