CSCommon: MMatchStatus.h 소스 파일

MAIET

MMatchStatus.h

00001 #ifndef _MMATCHSTATUS_H
00002 #define _MMATCHSTATUS_H
00003 
00004 class MMatchServer;
00005 
00006 class MMatchStatus
00007 {
00008 private:
00009     bool            m_bCreated;
00010     MMatchServer*   m_pMatchServer;
00011 protected:
00012     unsigned long int   m_nStartTime;
00013     unsigned long int   m_nTotalCommandQueueCount;
00014     unsigned long int   m_nTickCommandQueueCount;
00015 
00016 #define MSTATUS_MAX_CMD_COUNT       100000
00017 #define MSTATUS_MAX_DBQUERY_COUNT   60
00018 #define MSTATUS_MAX_CMD_HISTORY     20
00019 
00020     unsigned long int   m_nCmdCount[MSTATUS_MAX_CMD_COUNT][3];
00021     unsigned long int   m_nDBQueryCount[MSTATUS_MAX_DBQUERY_COUNT][3];
00022     unsigned long int   m_nCmdHistory[MSTATUS_MAX_CMD_HISTORY];
00023     int                 m_nHistoryCursor;
00024     int                 m_nRunStatus;
00025     void AddCmdHistory(unsigned long int nCmdID);
00026 public:
00027     MMatchStatus();
00028     virtual ~MMatchStatus();
00029     static MMatchStatus* GetInstance();
00030     bool Create(MMatchServer* pMatchServer);
00031 public:
00032     void SaveToLogFile();
00033     void AddCmdCount(unsigned long int nCmdCount)
00034     {
00035         m_nTickCommandQueueCount = nCmdCount;
00036         m_nTotalCommandQueueCount += m_nTickCommandQueueCount;
00037     }
00038     void AddCmd(unsigned long int nCmdID, int nCount = 1, unsigned long int nTime = 0)
00039     {
00040         AddCmdHistory(nCmdID);
00041 
00042         if (nCmdID >= MSTATUS_MAX_CMD_COUNT) return;
00043         m_nCmdCount[nCmdID][0] += nCount;
00044         m_nCmdCount[nCmdID][1] += nTime;
00045         m_nCmdCount[nCmdID][2] = nTime;
00046     }
00047     void AddDBQuery(unsigned long int nDBQueryID, unsigned long int nTime)
00048     {
00049         if (nDBQueryID >= MSTATUS_MAX_DBQUERY_COUNT) return;
00050 
00051         m_nDBQueryCount[nDBQueryID][0]++;
00052         m_nDBQueryCount[nDBQueryID][1] += nTime;
00053 
00054         m_nDBQueryCount[nDBQueryID][2] = nTime;
00055     }
00056     void SaveCmdHistory();
00057     void SetRunStatus(int value) { m_nRunStatus = value; }
00058 };
00059 
00060 inline MMatchStatus* MGetServerStatusSingleton() 
00061 {
00062     return MMatchStatus::GetInstance();
00063 }
00064 
00065 #endif


MAIET entertainment