#include "StdAfx.h" #include "TempServerSession.h" #include "AgentServerSession.h" #include "MasterServerSession.h" #include "ServerSessionFactory.h" ServerSessionFactory::ServerSessionFactory(void) { m_pTempServerPool = new CMemoryPoolFactory; m_pAgentServerPool = new CMemoryPoolFactory; m_pMasterServerPool = new CMemoryPoolFactory; } ServerSessionFactory::~ServerSessionFactory(void) { SAFE_DELETE( m_pTempServerPool ); SAFE_DELETE( m_pAgentServerPool ); SAFE_DELETE( m_pMasterServerPool ); } VOID ServerSessionFactory::Init( int nSize ) { m_pTempServerPool->Initialize( nSize, nSize/2 ); m_pAgentServerPool->Initialize( nSize, nSize/2 ); m_pMasterServerPool->Initialize( nSize, nSize/2 ); } ServerSession* ServerSessionFactory::AllocServerSession( eUPDATE_SERVER_TYPE eServerType ) { ServerSession *pServerSession = NULL; switch( eServerType ) { case UPDATE_TEMP: pServerSession = m_pTempServerPool->Alloc(); break; case UPDATE_AGENT: pServerSession = m_pAgentServerPool->Alloc(); break; case UPDATE_MASTER: pServerSession = m_pMasterServerPool->Alloc(); break; default: DISPMSG( "[ServerSessionFactory::AllocServerSession] À߸øµÈ ¼­¹ö ŸÀÔ[%d]ÀÌ´Ù.\n", eServerType ); return NULL; } return pServerSession; } BOOL ServerSessionFactory::FreeServerSession( ServerSession *pServerSession ) { if( !pServerSession ) return FALSE; switch( pServerSession->GetServerType() ) { case UPDATE_TEMP: return m_pTempServerPool->Free( (TempServerSession *)pServerSession ); case UPDATE_AGENT: return m_pAgentServerPool->Free( (AgentServerSession *)pServerSession ); case UPDATE_MASTER: return m_pMasterServerPool->Free( (MasterServerSession *)pServerSession ); default: { DISPMSG( "[ServerSessionFactory::FreeServerSession] À߸øµÈ ŸÀÔÀÇ ¼­¹ö¼¼¼ÇÀ» FreeÇÒ ¼ö ¾ø´Ù\n" ); } } return FALSE; }