Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
903 B

  1. //====== Copyright (c), Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef GCNETPACKETPOOL_H
  7. #define GCNETPACKETPOOL_H
  8. #include "netpacket.h"
  9. namespace GCSDK
  10. {
  11. class CNetPacket;
  12. extern int g_cNetPacket;
  13. extern CThreadSafeMultiMemoryPool g_MemPoolMsg;
  14. class CNetPacketPool
  15. {
  16. public:
  17. #ifdef _SERVER
  18. static int CMBPacketMemPool() { return ( CNetPacketPool::sm_MemPoolNetPacket.CubTotalSize() / k_nMegabyte ); }
  19. static int CMBPacketMemPoolInUse() { return ( CNetPacketPool::sm_MemPoolNetPacket.CubSizeInUse() / k_nMegabyte ); }
  20. #endif // _SERVER
  21. static CNetPacket *AllocNetPacket() { g_cNetPacket++; return sm_MemPoolNetPacket.Alloc(); }
  22. private:
  23. friend class CNetPacket;
  24. static CClassMemoryPool<CNetPacket> sm_MemPoolNetPacket;
  25. };
  26. } // namespace GCSDK
  27. #endif // GCNETPACKETPOOL_H