00001 #ifndef __MSGQ 00002 #define __MSGQ 00003 00004 00005 00006 #include "RainDefines.h" 00007 #include "RainMutex.h" 00008 #include "RainAutoArray.h" 00009 00010 00011 struct SRainMessage 00012 { 00013 UINT nID; 00014 UINT rgnData[4]; 00015 }; 00016 00017 00018 class CRainMessageQueue 00019 { 00020 public: 00021 CRainMessageQueue(); 00022 ~CRainMessageQueue(); 00023 00024 bool Init(UINT nSize); 00025 00026 00027 00028 00029 00030 00031 bool Push(const SRainMessage* pIn); 00032 int Pop(SRainMessage* pOut);//-1 on error, else number of items when this was called 00033 00034 private: 00035 void Cleanup(); 00036 00037 00038 CRainAutoArray<SRainMessage> m_Buffer; 00039 UINT m_nSize; 00040 UINT m_nPopPos;//points to the 'head' 00041 UINT m_nPushPos;//points to an empty spot 00042 00043 CRainMutex m_Mutex; 00044 }; 00045 00046 00047 00048 00049 00050 00051 #endif