#ifndef _WH_ALLOCATION_ID_H_ #define _WH_ALLOCATION_ID_H_ #include #include #include "ServiceCoreHead.h" using std::deque; using std::map; class SERVICE_CORE_CLASS WHAllocationID { private: CCriticalSection m_CriticalSection; //同步对象; deque m_allocationIDQueue; //随机ID的queue; map < int, bool > m_allocationIDMap; //随机ID的map; enum{ default_maxsize=10000 }; public: WHAllocationID(int nMaxSize = default_maxsize); ~WHAllocationID(){}; //重新分配更大Size; void ReAllocate( int nMaxSize ); //获得一个随机ID; int PopValue(); //归还分配出去的ID; void PushValue( int nID ); }; #endif