Threads.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWAudio *
  23. * *
  24. * $Archive:: /Commando/Code/WWAudio/Threads.h $Modtime:: 7/17/99 3:32p $*
  25. * *
  26. * $Revision:: 6 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #if defined(_MSC_VER)
  32. #pragma once
  33. #endif
  34. #ifndef __WWAUDIO_THREADS_H
  35. #define __WWAUDIO_THREADS_H
  36. #include "Windows.H"
  37. #include "Vector.H"
  38. #include "mutex.h"
  39. // Forward declarations
  40. class RefCountClass;
  41. //////////////////////////////////////////////////////////////////////////
  42. //
  43. // WWAudioThreadsClass
  44. //
  45. // Simple class that provides a common namespace for tying thread
  46. // information together.
  47. //
  48. //////////////////////////////////////////////////////////////////////////
  49. class WWAudioThreadsClass
  50. {
  51. public:
  52. //////////////////////////////////////////////////////////////////////
  53. // Public constructors/destructors
  54. //////////////////////////////////////////////////////////////////////
  55. WWAudioThreadsClass (void);
  56. ~WWAudioThreadsClass (void);
  57. //////////////////////////////////////////////////////////////////////
  58. // Public methods
  59. //////////////////////////////////////////////////////////////////////
  60. //
  61. // Delayed release mechanism
  62. //
  63. static HANDLE Create_Delayed_Release_Thread (LPVOID param = NULL);
  64. static void End_Delayed_Release_Thread (DWORD timeout = 20000);
  65. static void Add_Delayed_Release_Object (RefCountClass *object, DWORD delay = 2000);
  66. static void Flush_Delayed_Release_Objects (void);
  67. private:
  68. //////////////////////////////////////////////////////////////////////
  69. // Private methods
  70. //////////////////////////////////////////////////////////////////////
  71. static void __cdecl Delayed_Release_Thread_Proc (LPVOID param);
  72. //////////////////////////////////////////////////////////////////////
  73. // Private data types
  74. //////////////////////////////////////////////////////////////////////
  75. typedef struct _DELAYED_RELEASE_INFO
  76. {
  77. RefCountClass * object;
  78. DWORD time;
  79. _DELAYED_RELEASE_INFO *next;
  80. } DELAYED_RELEASE_INFO;
  81. //typedef DynamicVectorClass<DELAYED_RELEASE_INFO *> RELEASE_LIST;
  82. //////////////////////////////////////////////////////////////////////
  83. // Private member data
  84. //////////////////////////////////////////////////////////////////////
  85. static HANDLE m_hDelayedReleaseThread;
  86. static HANDLE m_hDelayedReleaseEvent;
  87. //static RELEASE_LIST m_ReleaseList;
  88. static CriticalSectionClass m_CriticalSection;
  89. static DELAYED_RELEASE_INFO * m_ReleaseListHead;
  90. static CriticalSectionClass m_ListMutex;
  91. static bool m_IsShuttingDown;
  92. };
  93. #endif //__WWAUDIO_THREADS_H