/* ==================================================================== * ÆÄ ÀÏ : ServerManager.h * ¸ñ Àû : * ÀÛ ¼º ÀÚ : °ûöÁß * ÀÛ ¼º ÀÏ : 08/10/17 * ÁÖÀÇ»çÇ× : * =================================================================== */ #ifndef __SERVER_MANAGER_H__ #define __SERVER_MANAGER_H__ //#ifndef WINVER //#define WINVER 0x0500 //#endif // //#ifndef _WIN32_WINNT //#define _WIN32_WINNT 0x0500 //#endif #pragma once #include "serverprotocol.h" struct PerChannel { long cid; // Connection Index (Server & Channel Number) BYTE status; // SERVER_STATUS ÂüÁ¶ DWORD timeToLive; // TIME TO LIVE struct PerChannel* next; // Linked List - next struct PerChannel* prev; // " - prev struct PerChannel* parent; // Binary Tree - Parent struct PerChannel* left; // " - Child, left struct PerChannel* right; // " - Child, right void Status ( BYTE s ) { status = s; } void TimeToLive ( DWORD t ) { timeToLive = t; } }; struct ServerTable { long idx; // °íÀ¯¹øÈ£ wchar_t name[51]; // À̸§ BYTE status; // SERVER_STATUS ÂüÁ¶ BYTE age; // Àû¿ë³ªÀÌ BYTE channelCounter; // ä³Î ¼ö DWORD concurrentUser; // µ¿½ÃÁ¢¼ÓÀÚ ¼ö DWORD minConcurrentUser; // ÃÖ¼Ò µ¿Á¢ÀÚ ¼ö DWORD maxConcurrentUser; // ÃÖ´ë µ¿Á¢ÀÚ ¼ö PerChannel* pool; // ä³Î Pool Æ÷ÀÎÅÍ PerChannel* root; // ä³Î BST Root Æ÷ÀÎÅÍ DWORD sms; // SMS Àü¼Û ¼ö }; #define MAX_SMS 32 // SMS ÃÖ´ë ¼ö class cServerManager { private: ServerTable mServerTable[ MAX_SERVER ]; PerChannel* mNonPagedPoolUsage; // ÆäÀÌÁö ¾ÈµÈ Ç®. SIZE_T mQuotaPagedPoolUsage; // ÇöÀç ÆäÀÌÁö µÈ Ç® - »ç¿ë·®. SIZE_T mQuotaNonPagedPoolUsage; // ÇöÀç ÆäÀÌÁö ¾ÈµÈ Ç® - »ç¿ë·®. SIZE_T mWorkingSetSize; // ÇöÀç ÀÛ¾÷ ¼³Á¤Å©±â. PerChannel* AllocChannel ( ); void FreeChannel ( PerChannel** pch ); int CompareCID ( PerChannel* pch1, PerChannel* pch2 ); int CompareCID ( long cid1, long cid2 ); void AttachPool ( PerChannel** pool, PerChannel* pch ); void DetachPool ( PerChannel** pool, PerChannel* pch ); bool AttachBst ( PerChannel** root, PerChannel* pch ); bool DetachBst ( PerChannel** root, PerChannel* pch ); PerChannel* GetPool ( ServerTable* serverTable, long cid ); void ReleasePool ( ServerTable* serverTable, PerChannel* pch ); public: cServerManager( ); void GetMemoryInfo ( SIZE_T& quotaPagedPoolUsage, SIZE_T& quotaNonPagedPoolUsage, SIZE_T& workingSetSize ); void Shutdown ( ); ServerTable* GetServerTable ( ) { return mServerTable; } ServerTable* GetServerTable ( long cid ); PerChannel* SearchChannel ( ServerTable* serverTable, long cid ); long FindChannel ( long cid ); PerChannel* GetChannel ( ServerTable* serverTable, long cid ); bool ReleaseChannel ( long cid ); void UpdateProcess ( DWORD currentTick ); public: virtual ~cServerManager(void); }; inline void cServerManager::GetMemoryInfo(SIZE_T& quotaPagedPoolUsage, SIZE_T& quotaNonPagedPoolUsage, SIZE_T& workingSetSize) { quotaPagedPoolUsage = mQuotaPagedPoolUsage; quotaNonPagedPoolUsage = mQuotaNonPagedPoolUsage; workingSetSize = mWorkingSetSize; } #endif // __SERVER_MANAGER_H__