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.

74 lines
1.2 KiB

  1. #ifndef _QUEUE_H
  2. #define _QUEUE_H
  3. #include "PssException.h"
  4. #include "Allocator.h"
  5. #define QUEUE_ELEMENT_DIR_BIT_SIZE ElementSize
  6. #define QUEUE_ELEMENT_DIR_SIZE 1 << QUEUE_ELEMENT_DIR_BIT_SIZE
  7. #define QUEUE_ELEMENT_DIR_MASK 0xFFFFFFFF >> ( 32 - QUEUE_ELEMENT_DIR_BIT_SIZE )
  8. template <class WmiElement, ULONG ElementSize >
  9. class WmiQueue
  10. {
  11. private:
  12. class WmiElementDir
  13. {
  14. public:
  15. WmiElementDir *m_Next ;
  16. WmiElement m_Block [ QUEUE_ELEMENT_DIR_SIZE ] ;
  17. WmiElementDir () { m_Next = NULL ; } ;
  18. ~WmiElementDir () { ; } ;
  19. } ;
  20. WmiElementDir *m_Top ;
  21. WmiElementDir *m_Tail ;
  22. ULONG m_TopIndex ;
  23. ULONG m_TailIndex ;
  24. ULONG m_Size ;
  25. ULONG m_AllocatedSize ;
  26. WmiAllocator &m_Allocator ;
  27. WmiStatusCode UnInitialize_ElementDir ( ULONG a_Size ) ;
  28. WmiStatusCode Grow_ElementDir () ;
  29. WmiStatusCode Shrink_ElementDir () ;
  30. public:
  31. WmiQueue (
  32. WmiAllocator &a_Allocator
  33. ) ;
  34. ~WmiQueue () ;
  35. WmiStatusCode Initialize () ;
  36. WmiStatusCode UnInitialize () ;
  37. WmiStatusCode EnQueue (
  38. const WmiElement &a_Element
  39. ) ;
  40. WmiStatusCode Top (
  41. WmiElement &a_Element
  42. ) ;
  43. WmiStatusCode DeQueue () ;
  44. ULONG Size () { return m_Size ; } ;
  45. } ;
  46. #include <Queue.cpp>
  47. #endif _QUEUE_H