Leaked source code of windows server 2003
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.

132 lines
3.1 KiB

  1. #ifndef __sipcli_asyncwi_h__
  2. #define __sipcli_asyncwi_h__
  3. #define WORKITEM_WINDOW_CLASS_NAME \
  4. _T("WorkItemWindowClass-c4572861-a2f6-41bd-afae-92538b59267b")
  5. #define WORKITEM_COMPLETION_WINDOW_CLASS_NAME \
  6. _T("WorkitemCompletionWindowClass-0ade6260-d1b4-483a-ae9d-42277907e898")
  7. // This class should store all the windows etc
  8. // and should be a member of the sip stack.
  9. class ASYNC_WORKITEM_MGR
  10. {
  11. public:
  12. ASYNC_WORKITEM_MGR();
  13. ~ASYNC_WORKITEM_MGR();
  14. HRESULT Start();
  15. HRESULT Stop();
  16. HRESULT CreateWorkItemWindow();
  17. VOID DestroyWorkItemWindow();
  18. VOID ShutdownWorkItemThread();
  19. inline BOOL WorkItemThreadShouldStop();
  20. inline HWND GetWorkItemWindow();
  21. inline HWND GetWorkItemCompletionWindow();
  22. private:
  23. HWND m_WorkItemWindow;
  24. HWND m_WorkItemCompletionWindow;
  25. HANDLE m_WorkItemThreadHandle;
  26. DWORD m_WorkItemThreadId;
  27. BOOL m_WorkItemThreadShouldStop;
  28. // BOOL m_WorkItemThreadHasStopped;
  29. HRESULT CreateWorkItemCompletionWindow();
  30. VOID DestroyWorkItemCompletionWindow();
  31. HRESULT StartWorkItemThread();
  32. };
  33. // This is an abstract base class providing the implemenation
  34. // for processing of async work items.
  35. // The following stuff specific to the work item needs to be
  36. // implemented for each work item.
  37. // Get WorkItemParam to start the work item
  38. // (done in the main thread).
  39. // Process WorkItemParam and obtain WorkItemResponse
  40. // (done in the async work item thread).
  41. // Process WorkItemResponse and make callback.
  42. // (done in the main thread).
  43. // Note that even though the work item object is accessed by
  44. // the main thread and the async work item thread, they never
  45. // access the same member at the same time.
  46. class __declspec(novtable) ASYNC_WORKITEM
  47. {
  48. public:
  49. ASYNC_WORKITEM(
  50. IN ASYNC_WORKITEM_MGR *pWorkItemMgr
  51. );
  52. virtual ~ASYNC_WORKITEM();
  53. HRESULT StartWorkItem();
  54. VOID CancelWorkItem();
  55. VOID OnWorkItemComplete();
  56. VOID ProcessWorkItemAndPostResult();
  57. // virtual HRESULT GetWorkItemParam() = 0;
  58. virtual VOID ProcessWorkItem() = 0;
  59. virtual VOID NotifyWorkItemComplete() = 0;
  60. private:
  61. ASYNC_WORKITEM_MGR *m_pWorkItemMgr;
  62. BOOL m_WorkItemCanceled;
  63. inline HWND GetWorkItemWindow();
  64. inline HWND GetWorkItemCompletionWindow();
  65. };
  66. inline BOOL
  67. ASYNC_WORKITEM_MGR::WorkItemThreadShouldStop()
  68. {
  69. return m_WorkItemThreadShouldStop;
  70. }
  71. inline HWND
  72. ASYNC_WORKITEM_MGR::GetWorkItemWindow()
  73. {
  74. return m_WorkItemWindow;
  75. }
  76. inline HWND
  77. ASYNC_WORKITEM_MGR::GetWorkItemCompletionWindow()
  78. {
  79. return m_WorkItemCompletionWindow;
  80. }
  81. inline HWND
  82. ASYNC_WORKITEM::GetWorkItemWindow()
  83. {
  84. return m_pWorkItemMgr->GetWorkItemWindow();
  85. }
  86. inline HWND
  87. ASYNC_WORKITEM::GetWorkItemCompletionWindow()
  88. {
  89. return m_pWorkItemMgr->GetWorkItemCompletionWindow();
  90. }
  91. #endif // __sipcli_asyncwi_h__