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.

129 lines
3.2 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. CLICNT.H
  5. Abstract:
  6. Generic class for obtaining read and write locks to some resource.
  7. History:
  8. 26-Mar-98 a-davj Created.
  9. --*/
  10. #ifndef __CLICNT__H_
  11. #define __CLICNT__H_
  12. #include <statsync.h>
  13. #include <flexarry.h>
  14. //*****************************************************************************
  15. //
  16. // class CClientCnt
  17. //
  18. // Keeps track of when the core can be unloaded. Mainly it keep track of client connections,
  19. // but also can be called by other core code, such as the maintenance thread, to hold off
  20. // unloading. This is very similar to the object counters, except this keeps track of only
  21. // objects which should prevent the core from unloading. For example, a IWbemServices pointer used
  22. // internally for the ESS should not be in this list, but one given to a client would be.
  23. //
  24. //*****************************************************************************
  25. //
  26. // AddClientPtr
  27. //
  28. // Typcially called during the constructor of an object that has been given to a client
  29. //
  30. // Parameters:
  31. //
  32. // IUnknown * punk Pointer to an obejct.
  33. // DWORD dwType Type of pointer
  34. //
  35. // Returns:
  36. //
  37. // true if OK
  38. //
  39. //*****************************************************************************
  40. //
  41. // RemoveClientPtr
  42. //
  43. // Typically called during the destructor of an object that might have been given to
  44. // a client. Note that the code will search through the list of objects added and find
  45. // the object before doing anything. So if the pointer is to an object not added via
  46. // AddClientPtr is passed, no harm is done. This is important in the case of objects which
  47. // are not always given to a client.
  48. //
  49. // Parameters:
  50. //
  51. // IUnknown * punk Pointer to an obejct.
  52. //
  53. // Returns:
  54. //
  55. // true if removed.
  56. // flase is not necessarily a problem!
  57. //*****************************************************************************
  58. //
  59. // LockCore
  60. //
  61. // Called in order to keep the core loaded. This is called by the maintenance thread
  62. // in order to hold the core in memory. Note that this acts like the LockServer call in
  63. // that serveral threads can call this an not block. UnlockCore should be called when
  64. // the core is not needed anymore.
  65. //
  66. // Returns:
  67. //
  68. // long LockCount after call
  69. //
  70. //*****************************************************************************
  71. //
  72. // UnlockCore
  73. //
  74. // Called to reverse the effect of LockCore.
  75. //
  76. // Returns:
  77. //
  78. // long LockCount after call
  79. //
  80. //*****************************************************************************
  81. enum ClientObjectType
  82. {
  83. CALLRESULT = 0,
  84. NAMESPACE,
  85. LOGIN,
  86. FACTORY,
  87. DECORATOR,
  88. CORESVC,
  89. ESSSINK,
  90. LOCATOR,
  91. INT_PROV
  92. };
  93. struct Entry
  94. {
  95. IUnknown * m_pUnk;
  96. ClientObjectType m_Type;
  97. };
  98. class CClientCnt
  99. {
  100. public:
  101. bool AddClientPtr(LIST_ENTRY * pEntry);
  102. bool RemoveClientPtr(LIST_ENTRY * pEntry);
  103. bool OkToUnload();
  104. CClientCnt();
  105. ~CClientCnt();
  106. protected:
  107. CStaticCritSec m_csEntering; // this object is global, that's why we use CStaticCritSec
  108. LIST_ENTRY m_Head;
  109. LONG m_Count;
  110. void SignalIfOkToUnload();
  111. };
  112. #endif