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.

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