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.

144 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1994-1997 Microsoft Corporation
  3. Module Name :
  4. wamstats.hxx
  5. Abstract:
  6. Declares a class consisting of statistics information.
  7. ( Multiple instances of the same object can be created for reuse)
  8. Author:
  9. Murali R. Krishnan ( MuraliK ) 04-Nov-1994
  10. Project:
  11. Web Application Manager DLL
  12. Revision History:
  13. Murali R. Krishnan ( MuraliK ) 1-Apr-1997
  14. --*/
  15. # ifndef _WAMSTATS_HXX_
  16. # define _WAMSTATS_HXX_
  17. /************************************************************
  18. * Include Headers
  19. ************************************************************/
  20. # include "iperfctr.hxx" // standard macro defs for counters
  21. # include "wam.h"
  22. /************************************************************
  23. * Type Definitions
  24. ************************************************************/
  25. # define IPWAM_STATS_INCR( ctrName) \
  26. void Incr ## ctrName(void) \
  27. { \
  28. IP_INCREMENT_COUNTER( m_WamStats.ctrName); \
  29. }
  30. # define IPWAM_STATS_DECR( ctrName) \
  31. void Decr ## ctrName(void) \
  32. { \
  33. IP_DECREMENT_COUNTER( m_WamStats.ctrName); \
  34. }
  35. # define IPWAM_STATS_QUERY( ctrName) \
  36. LONG Query ## ctrName(void) \
  37. { \
  38. return (IP_COUNTER_VALUE( m_WamStats.ctrName)); \
  39. }
  40. //
  41. // A counter inside the statistics block should use the following three
  42. // macros for defining "query", "incr" and "decr" methods inside
  43. // the statistics object
  44. //
  45. # define IPWAM_STATS_COUNTER( ctrName) \
  46. IPWAM_STATS_INCR( ctrName); \
  47. IPWAM_STATS_DECR( ctrName); \
  48. IPWAM_STATS_QUERY( ctrName); \
  49. class WAM_STATISTICS {
  50. private:
  51. WAM_STATISTICS_0 m_WamStats;
  52. // local lock to synchronize access among threads
  53. // NYI: SPIN-COUNT
  54. CRITICAL_SECTION m_csStatsLock;
  55. public:
  56. VOID LockStatistics( VOID) { EnterCriticalSection( &m_csStatsLock); }
  57. VOID UnlockStatistics( VOID) { LeaveCriticalSection( &m_csStatsLock); }
  58. WAM_STATISTICS( VOID);
  59. ~WAM_STATISTICS( VOID)
  60. { DeleteCriticalSection( &m_csStatsLock); };
  61. VOID ClearStatistics( VOID);
  62. //
  63. // copies statistics for RPC querying.
  64. //
  65. DWORD CopyToStatsBuffer( PWAM_STATISTICS_0 pStat0 );
  66. // BGI Requests
  67. void IncrWamRequests( void);
  68. IPWAM_STATS_INCR( CurrentWamRequests);
  69. IPWAM_STATS_QUERY( CurrentWamRequests);
  70. IPWAM_STATS_DECR( CurrentWamRequests);
  71. IPWAM_STATS_COUNTER( TotalWamRequests);
  72. }; // WAM_STATISTICS
  73. typedef WAM_STATISTICS FAR * PWAM_STATISTICS;
  74. /************************************************************
  75. * Inline Methods
  76. ************************************************************/
  77. inline void WAM_STATISTICS::IncrWamRequests(void)
  78. {
  79. # ifdef IP_ENABLE_COUNTERS
  80. IncrTotalWamRequests();
  81. IncrCurrentWamRequests();
  82. if ( m_WamStats.CurrentWamRequests > m_WamStats.MaxWamRequests )
  83. {
  84. LockStatistics();
  85. if ( m_WamStats.CurrentWamRequests > m_WamStats.MaxWamRequests )
  86. m_WamStats.MaxWamRequests = m_WamStats.CurrentWamRequests;
  87. UnlockStatistics();
  88. }
  89. # endif // IP_ENABLE_COUNTERS
  90. return;
  91. } // WAM_STATISTICS::IncrWamRequests()
  92. # endif // _WAMSTATS_HXX_
  93. /************************ End of File ***********************/