rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWVirtualPageHeap Class Reference
[File System]

Deprecated. Abstract base class representing an abstract page heap of fixed-sized pages. More...

#include <rw/vpage.h>

Inheritance diagram for RWVirtualPageHeap:
RWBufferedPageHeap RWDiskPageHeap

List of all members.

Public Member Functions

 RWVirtualPageHeap (unsigned pgsize)
virtual ~RWVirtualPageHeap ()
unsigned pageSize () const
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
virtual void unlock (size_t)=0

Detailed Description

Deprecated:
RWVirtualPageHeap is deprecated and is no longer supported. It may be removed from future releases.

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<T>, which represents a virtual array of elements of type T. Elements are automatically swapped in as necessary as they are addressed.

Synopsis

 #include <rw/vpage.h>
 (Abstract base class)

Persistence

None


Constructor & Destructor Documentation

RWVirtualPageHeap::RWVirtualPageHeap ( unsigned  pgsize  )  [inline]

Sets the size of a page.

virtual RWVirtualPageHeap::~RWVirtualPageHeap (  )  [inline, virtual]

Virtual destructor, allowing specializing classes a chance to deallocate any resources that they may have allocated.


Member Function Documentation

virtual size_t RWVirtualPageHeap::allocate (  )  [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 RWBufferedPageHeap, and RWDiskPageHeap.

virtual void RWVirtualPageHeap::deallocate ( size_t  h  )  [pure virtual]

Deallocate the page associated with handle h. It is not an error to deallocate a zero handle.

Implemented in RWBufferedPageHeap, and RWDiskPageHeap.

virtual void RWVirtualPageHeap::dirty ( size_t  h  )  [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.

virtual void* RWVirtualPageHeap::lock ( size_t   )  [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.

unsigned RWVirtualPageHeap::pageSize (  )  const [inline]

Returns the page size for this abstract page heap.

virtual void RWVirtualPageHeap::unlock ( size_t   )  [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.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.