SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Deprecated. Abstract base class representing an abstract page heap of fixed-sized pages. More...
#include <rw/vpage.h>
Public Member Functions | |
RWVirtualPageHeap (unsigned pgsize) | |
virtual | ~RWVirtualPageHeap () |
virtual size_t | allocate ()=0 |
virtual void | deallocate (size_t h)=0 |
virtual void | dirty (size_t h)=0 |
virtual void * | lock (size_t)=0 |
unsigned | pageSize () const |
virtual void | unlock (size_t)=0 |
RWVirtualPageHeap is an abstract base class representing an abstract page heap of fixed sized pages. Specializing classes should work as follows:
Allocate a page off the abstract heap by calling member function allocate(), which returns a memory "handle," an object of type size_t
. This handle logically represents the page.
In order to use the page, it must first be "locked" by calling member function lock() with the handle as an argument. The specializing class of RWVirtualPageHeap must make whatever arrangements are necessary to swap in the page associated with the handle and bring it into physical memory. The actual swapping medium could be disk, expanded or extended memory, or a machine on a network. Upon return, lock() returns a pointer to the page, now residing in memory.
Once a page is in memory, you are free to do anything you want with it, although if you change the contents, you must call member function dirty() before unlocking the page.
Locked pages use up memory. In fact, some specializing classes have only a fixed number of buffers in which to do their swapping. If you are not using the page, you should call unlock(). After calling unlock() the original address returned by lock() is no longer valid – to use the page again, it must be locked again with lock().
When you are completely done with the page, then call deallocate() to return it to the abstract heap.
In practice, managing this locking and unlocking and the inevitable type casts can be difficult. It is usually easier to design a class that can work with an abstract heap to bring things in and out of memory automatically. Indeed, this is what has been done with class RWTValVirtualArray, which represents a virtual array of elements of type T
. Elements are automatically swapped in as necessary as they are addressed.
|
inline |
Sets the size of a page.
|
inlinevirtual |
Virtual destructor, allowing specializing classes a chance to deallocate any resources that they may have allocated.
|
pure virtual |
Allocates a page off the abstract heap and returns a handle for it. If the specializing class is unable to honor the request, then it should return a zero handle.
Implemented in RWDiskPageHeap, and RWBufferedPageHeap.
|
pure virtual |
Deallocate the page associated with handle h. It is not an error to deallocate a zero handle.
Implemented in RWDiskPageHeap, and RWBufferedPageHeap.
|
pure virtual |
Declare the page associated with handle h to be "dirty." That is, it has changed since it was last locked. The page must be locked before calling this function.
Implemented in RWBufferedPageHeap.
|
pure virtual |
Lock the page, swapping it into physical memory, and return an address for it. Returns rwnil if the specializing class is unable to honor the lock. The returned pointer should be regarded as pointing to a buffer of the page size.
Implemented in RWBufferedPageHeap.
|
inline |
Returns the page size for this abstract page heap.
|
pure virtual |
Unlock a page. A page must be locked before calling this function. After calling this function, the address returned by lock() is no longer valid.
Implemented in RWBufferedPageHeap.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |