Source code of Windows XP (NT5)
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.

41 lines
1.0 KiB

  1. typedef BOOL (* THREADCALLBACK)(PVOID pParam, DWORD dwParam);
  2. // general purpose worker thread
  3. // The thread exists in an alertable Wait state and does most of its work
  4. // in APCs.
  5. struct ThreadCallback
  6. {
  7. THREADCALLBACK CallProc;
  8. PVOID pParam;
  9. DWORD dwParam;
  10. };
  11. class CEventThread
  12. {
  13. public:
  14. CEventThread();
  15. ~CEventThread();
  16. int Start();
  17. int Stop();
  18. BOOL CallNow(THREADCALLBACK CallProc, PVOID pParam, DWORD dwParam);
  19. //BOOL WaitOnEvent(THREADCALLBACK OnEventProc, PVOID pParam, DWORD dwParam);
  20. private:
  21. #define CTHREADF_STOP 0x00000001
  22. static DWORD __stdcall EventThreadProc(PVOID pObj)
  23. {
  24. return ((class CEventThread *)pObj)->ThreadMethod();
  25. }
  26. static void APIENTRY HandleCallNowAPC(DWORD dwArg);
  27. DWORD ThreadMethod();
  28. HANDLE m_hThread;
  29. DWORD m_idThread;
  30. UINT m_uRef;
  31. HANDLE m_hSignalEvent; // signal to worker thread to do something
  32. HANDLE m_hAckEvent; // ack from worker thread
  33. DWORD m_dwFlags;
  34. CRITICAL_SECTION m_cs; // serializes client calls. Not used by worker thread
  35. ThreadCallback m_Callback;
  36. };