CacheAllocator Class Reference

CacheAllocator defines an interface for allocating memory pages to be used by the cache. More...

#include <CacheAllocator.h>

Inheritance diagram for CacheAllocator:

VMAllocator List of all members.

Public Member Functions

virtual ~CacheAllocator ()
virtual void * allocate (int *pErrorCode=NULL)=0
 Allocates a chunk of memory of size determined by the constructor.
virtual int deallocate (void *pMem, int *pErrorCode=NULL)=0
 Deallocates a chunk of memory.
virtual size_t getBytesAllocated () const=0
 
Returns:
number of bytes currently allocated

virtual int setProtection (void *pMem, uint cb, bool readOnly, int *pErrorCode=NULL)=0
 Changes protection state for a contiguous range of virtual memory.

Detailed Description

CacheAllocator defines an interface for allocating memory pages to be used by the cache.

Definition at line 33 of file CacheAllocator.h.


Constructor & Destructor Documentation

CacheAllocator::~CacheAllocator (  )  [virtual]

Definition at line 29 of file CacheAllocator.cpp.

00030 {
00031 }


Member Function Documentation

virtual void* CacheAllocator::allocate ( int *  pErrorCode = NULL  )  [pure virtual]

Allocates a chunk of memory of size determined by the constructor.

Parameters:
pErrorCode on error and if non-NULL, the int referenced is modified to contain the OS error code
Returns:
the allocated chunk; NULL if memory cannot be allocated (see pErrorCode for OS error code)

Implemented in VMAllocator.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), and CacheImpl< PageT, VictimPolicyT >::setAllocatedPageCount().

virtual int CacheAllocator::deallocate ( void *  pMem,
int *  pErrorCode = NULL 
) [pure virtual]

Deallocates a chunk of memory.

Parameters:
pMem the allocated memory
pErrorCode on error and if non-NULL, the int referenced is modified to contain the OS error code
Returns:
0 on success; -1 if memory cannot be deallocated (see pErrorCode for OS error code)

Implemented in VMAllocator.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), CacheImpl< PageT, VictimPolicyT >::closeImpl(), and CacheImpl< PageT, VictimPolicyT >::setAllocatedPageCount().

virtual size_t CacheAllocator::getBytesAllocated (  )  const [pure virtual]

Returns:
number of bytes currently allocated

Implemented in VMAllocator.

virtual int CacheAllocator::setProtection ( void *  pMem,
uint  cb,
bool  readOnly,
int *  pErrorCode = NULL 
) [pure virtual]

Changes protection state for a contiguous range of virtual memory.

Parameters:
pMem start of range
cb number of bytes in range
readOnly true for read-only; false for read-write (TODO jvs 7-Feb-2006: support no-access as well)
pErrorCode on error and if non-NULL, the int referenced is modified to contain the OS error code
Returns:
0 on success; -1 if an error occurs while manupulating memory protections (see pErrorCode for OS error code)

Implemented in VMAllocator.


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:27 2009 for Fennel by  doxygen 1.5.1