📄 msgque.h
字号:
// MsgQue.h: interface for the MsgQue class.
//
//////////////////////////////////////////////////////////////////////
//File Name: MsgQue.h: implementation of the MsgQue and SafeMsgQue structure.
//References: MSDN
//Purpose: To implement a Safe Message Queue and some functions about it.
//History
//*Data *Name *comments.
//2008-Feb-03 Rock Li Initialization
#if !defined(AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_)
#define AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma pack(1)
// message queue ;pragma pack(1) means align is 1 byte;
struct tag_MsgQue
{
unsigned char Buf[256];
struct tag_MsgQue* next;
} ;
#pragma pack()
typedef struct tag_MsgQue* pMsgQue;
typedef struct tag_MsgQue MsgQue;
typedef struct tag_MsgQue MsgNode;
struct tag_SafeMsgQue
{
pMsgQue pMsg; //Message queue
pMsgQue pHead; //the head of the Message queue
pMsgQue pTail; //the tail of the Message queue
HANDLE hProExitEvn; // program exit event; it should be passed by the caller.
HANDLE hOpSem; // Operation semaphore; 0/1 semaphore
HANDLE hMsgSem; // Message(s) exits. if there is one or more messages in the queue, the falg of hMsgSem is ture.
};
typedef struct tag_SafeMsgQue* pSafeMsgQue;
typedef struct tag_SafeMsgQue SafeMsgQue;
bool SafeMsgQueInit(HANDLE hProExit, pSafeMsgQue pSafeQue);
bool ReadOneMsg(pMsgQue* pMsg, pSafeMsgQue pSafeQue);
bool InsertOneMsg(pMsgQue pMsg, pSafeMsgQue pSafeQue);
bool LockQue(pSafeMsgQue pSafeQue);
bool UnlockQue(pSafeMsgQue pSafeQue);
#endif // !defined(AFX_MSGQUE_H__28076F41_8497_451E_B1E2_8765051DF2AC__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -