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.

149 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. cache.hxx
  5. Abstract:
  6. This class models a cache of equal sized blocks.
  7. Author:
  8. Norbert Kusters (norbertk) 1-Nov-91
  9. --*/
  10. #if !defined(_CACHE_DEFN_)
  11. #define _CACHE_DEFN_
  12. #include "bigint.hxx"
  13. DECLARE_CLASS(CACHE);
  14. class CACHE : public OBJECT {
  15. public:
  16. DECLARE_CONSTRUCTOR( CACHE );
  17. VIRTUAL
  18. ~CACHE(
  19. );
  20. NONVIRTUAL
  21. BOOLEAN
  22. Initialize(
  23. IN ULONG BlockSize,
  24. IN ULONG MaximumNumberOfBlocks
  25. );
  26. NONVIRTUAL
  27. BOOLEAN
  28. Read(
  29. IN BIG_INT BlockNumber,
  30. OUT PVOID Buffer
  31. ) CONST;
  32. NONVIRTUAL
  33. VOID
  34. AddBlock(
  35. IN BIG_INT BlockNumber,
  36. IN PCVOID Buffer
  37. );
  38. NONVIRTUAL
  39. VOID
  40. Empty(
  41. );
  42. NONVIRTUAL
  43. ULONG
  44. QueryMaxNumBlocks(
  45. ) CONST;
  46. NONVIRTUAL
  47. ULONG
  48. QueryBlockSize(
  49. ) CONST;
  50. private:
  51. NONVIRTUAL
  52. VOID
  53. Construct(
  54. );
  55. NONVIRTUAL
  56. VOID
  57. Destroy(
  58. );
  59. PVOID* _buffer;
  60. PBIG_INT _block_number;
  61. PLONG _inuse;
  62. ULONG _num_blocks;
  63. ULONG _block_size;
  64. ULONG _next_add;
  65. LONG _next_add_inuse;
  66. LARGE_INTEGER _timeout;
  67. };
  68. INLINE
  69. ULONG
  70. CACHE::QueryMaxNumBlocks(
  71. ) CONST
  72. /*++
  73. Routine Description:
  74. This routine returns the number of cache blocks used by this object.
  75. Arguments:
  76. None.
  77. Return Value:
  78. The maximum number of cache blocks.
  79. --*/
  80. {
  81. return _num_blocks;
  82. }
  83. INLINE
  84. ULONG
  85. CACHE::QueryBlockSize(
  86. ) CONST
  87. /*++
  88. Routine Description:
  89. This routine returns the number of bytes per block.
  90. Arguments:
  91. None.
  92. Return Value:
  93. The number of bytes per block.
  94. --*/
  95. {
  96. return _block_size;
  97. }
  98. #endif // _CACHE_DEFN_