home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWBUFPAGE_H__
- #define __RWBUFPAGE_H__
- pragma push_align_members(64);
-
- /*
- * RWBufferedPageHeap: A virtual page heap accessed through a buffer
- *
- * $Header: E:/vcs/rw/bufpage.h_v 1.0 11 Mar 1992 14:09:58 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave Software, Inc.
- * P.O. Box 2328
- * Corvallis, OR 97339
- *
- * Copyright (C) 1992. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/bufpage.h_v $
- *
- * Rev 1.0 11 Mar 1992 14:09:58 KEFFER
- * Initial revision.
- */
-
- #include "rw/vpage.h"
- STARTWRAP
- #include <stddef.h>
- ENDWRAP
-
- class RWExport RWBufferedPageHeap : public RWVirtualPageHeap {
- unsigned _nBuffers; // Number of buffers (each is pageSize() big)
- RWvoid* _buffers; // Points to an array of pointers to buffers
- RWHandle* _handles; // Page handle associated with each buffer
- short* _lockCounts; // Lock count for each buffer
- unsigned* _age; // Age of buffer since accessed
- RWBoolean* _dirty; // Whether this buffer has changed since swap in
- protected:
- int ageAndFindHandle(RWHandle); // Find slot for given handle and age all slots
- int findHandle(RWHandle); // Find slot for given handle
- int findUnusedSlot(); // Find an unused slot
- int swapPageIn(RWHandle); // Swap in page with given handle
- int swapOutLRUSlot(); // Swap out the Least Recently Used page
- virtual RWBoolean swapIn(RWHandle, void*) = 0; // Supplied by specializing class
- virtual RWBoolean swapOut(RWHandle, void*) = 0;
- public:
- RWBufferedPageHeap(unsigned pgsize, unsigned nbufs=10);
- virtual ~RWBufferedPageHeap();
-
- RWBoolean isValid() {return _buffers!=NULL;}
-
- // Inherited from RWVirtualPageHeap:
- virtual RWHandle allocate() = 0; // Allocate a page
- virtual void deallocate(RWHandle); // Deallocate it
- virtual void dirty(RWHandle); // Declare page as dirty
- virtual void* lock(RWHandle); // Lock a page
- virtual void unlock(RWHandle); // Unlock a page
- };
-
- pragma pop_align_members();
- #endif /* __RWBUFPAGE_H__ */
-