home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / N0 < prev    next >
Encoding:
Text File  |  1992-06-07  |  1.9 KB  |  63 lines

  1. #ifndef __RWCACHEMAN_H__
  2. #define __RWCACHEMAN_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWCacheManager --- caches fixed length blocks to and from disk
  7.  *
  8.  * $Header:   E:/vcs/rw/cacheman.h_v   1.2   18 Feb 1992 09:54:10   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * $Log:   E:/vcs/rw/cacheman.h_v  $
  23.  * 
  24.  *    Rev 1.2   18 Feb 1992 09:54:10   KEFFER
  25.  * 
  26.  *    Rev 1.1   28 Oct 1991 09:08:08   keffer
  27.  * Changed inclusions to <rw/xxx.h>
  28.  * 
  29.  *    Rev 1.0   28 Jul 1991 08:12:58   keffer
  30.  * Tools.h++ V4.0.5 PVCS baseline version
  31.  *
  32.  */
  33.  
  34. #include "rw/tooldefs.h"
  35.  
  36. class RWExport RWCacheManager {
  37.   RWFile*        theFile;
  38.   unsigned        maxblocks; // Max # blocks in buffer
  39.   unsigned        nused;       // Number being used.
  40.   unsigned        blocksize; // Size of a block
  41.   RWoffset*        diskAddrs; // Its disk address
  42.   unsigned*        useCounts; // Use count for the block
  43.   char*            buff;       // The set of blocks.
  44. private:
  45.   RWCacheManager(const RWCacheManager&); // Private to insure no copies
  46.   void            operator=(const RWCacheManager&); // Ditto
  47.   int            ageAndFindSlot(RWoffset);
  48.   RWBoolean        flush(int);
  49.   int            getFreeSlot();
  50.   int            LRU() const; // Find least recently used block
  51. public:
  52.   RWCacheManager(RWFile* file, unsigned blocksz, unsigned mxblks = 10);
  53.   ~RWCacheManager();
  54.  
  55.   RWBoolean        flush();    // Perform any pending writes.
  56.   void            invalidate();    // Invalidate the entire cache
  57.   RWBoolean        read(RWoffset locn, void* dat);
  58.   RWBoolean        write(RWoffset locn, void* dat);
  59. };
  60.  
  61. pragma pop_align_members();
  62. #endif
  63.