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

  1. #ifndef __RWBUFPAGE_H__
  2. #define __RWBUFPAGE_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWBufferedPageHeap: A virtual page heap accessed through a buffer
  7.  *
  8.  * $Header:   E:/vcs/rw/bufpage.h_v   1.0   11 Mar 1992 14:09:58   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave Software, Inc.
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  *
  16.  * Copyright (C) 1992. This software is subject to copyright 
  17.  * protection under the laws of the United States and other countries.
  18.  *
  19.  ***************************************************************************
  20.  *
  21.  * $Log:   E:/vcs/rw/bufpage.h_v  $
  22.  * 
  23.  *    Rev 1.0   11 Mar 1992 14:09:58   KEFFER
  24.  * Initial revision.
  25.  */
  26.  
  27. #include "rw/vpage.h"
  28. STARTWRAP
  29. #include <stddef.h>
  30. ENDWRAP
  31.  
  32. class RWExport RWBufferedPageHeap : public RWVirtualPageHeap {
  33.   unsigned        _nBuffers;    // Number of buffers (each is pageSize() big)
  34.   RWvoid*        _buffers;    // Points to an array of pointers to buffers
  35.   RWHandle*        _handles;    // Page handle associated with each buffer
  36.   short*        _lockCounts;    // Lock count for each buffer
  37.   unsigned*        _age;        // Age of buffer since accessed
  38.   RWBoolean*        _dirty;        // Whether this buffer has changed since swap in
  39. protected:
  40.   int            ageAndFindHandle(RWHandle);    // Find slot for given handle and age all slots
  41.   int            findHandle(RWHandle);        // Find slot for given handle
  42.   int            findUnusedSlot();        // Find an unused slot
  43.   int            swapPageIn(RWHandle);        // Swap in page with given handle
  44.   int            swapOutLRUSlot();        // Swap out the Least Recently Used page
  45.   virtual RWBoolean    swapIn(RWHandle, void*)  = 0;    // Supplied by specializing class
  46.   virtual RWBoolean    swapOut(RWHandle, void*) = 0;
  47. public:
  48.   RWBufferedPageHeap(unsigned pgsize, unsigned nbufs=10);
  49.   virtual        ~RWBufferedPageHeap();
  50.  
  51.   RWBoolean        isValid()        {return _buffers!=NULL;}
  52.  
  53.   // Inherited from RWVirtualPageHeap:
  54.   virtual RWHandle    allocate()           = 0;    // Allocate a page
  55.   virtual void        deallocate(RWHandle);        // Deallocate it
  56.   virtual void        dirty(RWHandle);        // Declare page as dirty
  57.   virtual void*        lock(RWHandle);            // Lock a page
  58.   virtual void        unlock(RWHandle);        // Unlock a page
  59. };
  60.  
  61. pragma pop_align_members();
  62. #endif    /* __RWBUFPAGE_H__ */
  63.