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.

118 lines
2.4 KiB

  1. /*++
  2. Copyright(c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. brdgwait.h
  5. Abstract:
  6. Ethernet MAC level bridge
  7. WAIT_REFCOUNT implementation
  8. Author:
  9. Mark Aiken
  10. Environment:
  11. Kernel mode driver
  12. Revision History:
  13. Feb 2000 - Original version
  14. --*/
  15. // ===========================================================================
  16. //
  17. // DECLARATIONS
  18. //
  19. // ===========================================================================
  20. //
  21. // Structure for a refcount that can be waited against (when waiting for 0)
  22. //
  23. typedef enum
  24. {
  25. WaitRefEnabled = 0,
  26. WaitRefShuttingDown,
  27. WaitRefShutdown
  28. } WAIT_REFCOUNT_STATE;
  29. typedef struct _WAIT_REFCOUNT
  30. {
  31. LONG Refcount; // The refcount
  32. NDIS_EVENT Event; // Signaled when RefCount hits 0
  33. WAIT_REFCOUNT_STATE state; // Current state
  34. BOOLEAN bResettable; // TRUE if it's OK to reset this
  35. // refcount when state == WaitRefShuttingDown
  36. NDIS_SPIN_LOCK lock; // Protects fields above
  37. } WAIT_REFCOUNT, *PWAIT_REFCOUNT;
  38. // ===========================================================================
  39. //
  40. // PROTOTYPES
  41. //
  42. // ===========================================================================
  43. VOID
  44. BrdgInitializeWaitRef(
  45. IN PWAIT_REFCOUNT pRefcount,
  46. IN BOOLEAN bResettable
  47. );
  48. BOOLEAN
  49. BrdgIncrementWaitRef(
  50. IN PWAIT_REFCOUNT pRefcount
  51. );
  52. VOID
  53. BrdgReincrementWaitRef(
  54. IN PWAIT_REFCOUNT pRefcount
  55. );
  56. VOID
  57. BrdgDecrementWaitRef(
  58. IN PWAIT_REFCOUNT pRefcount
  59. );
  60. VOID
  61. BrdgBlockWaitRef(
  62. IN PWAIT_REFCOUNT pRefcount
  63. );
  64. BOOLEAN
  65. BrdgShutdownBlockedWaitRef(
  66. IN PWAIT_REFCOUNT pRefcount
  67. );
  68. BOOLEAN
  69. BrdgShutdownWaitRef(
  70. IN PWAIT_REFCOUNT pRefcount
  71. );
  72. //
  73. // Use when it should be impossible for two or more threads of
  74. // execution to simultaneously shut down your waitref.
  75. //
  76. __inline
  77. VOID
  78. BrdgShutdownWaitRefOnce(
  79. IN PWAIT_REFCOUNT pRefcount
  80. )
  81. {
  82. BOOLEAN bSuccess = FALSE;
  83. bSuccess = BrdgShutdownWaitRef( pRefcount );
  84. SAFEASSERT( bSuccess );
  85. }
  86. VOID
  87. BrdgResetWaitRef(
  88. IN PWAIT_REFCOUNT pRefcount
  89. );