#include <PageCache.h>
Public Types | |
| typedef std::list < CachedPage::UnitPtr > | UnitList |
Public Member Functions | |
| PageCache (const size_t maxCacheSize=20000000) | |
| ~PageCache () | |
| CachedPage::UnitPtr | getUnit (DataRequest *pOriginalRequest, DimensionDescriptor startRow, DimensionDescriptor startBand) |
| void | initialize (int bytesPerBand, int columnCount, int bandCount) |
| CachedPage * | createPage (CachedPage::UnitPtr pUnit, InterleaveFormatType requestedFormat, DimensionDescriptor startRow, DimensionDescriptor startColumn, DimensionDescriptor startBand) |
Protected Member Functions | |
| void | enforceCacheSize () |
Protected Attributes | |
| const size_t | MAX_CACHE_SIZE |
| UnitList | mUnits |
| std::string | mFilename |
| size_t | mCacheSize |
| int | mBytesPerBand |
| int | mColumnCount |
| int | mBandCount |
For example, a multi-threaded algorithm could get a DataAccessor to odd and even rows. These two threads would be able to share the same page.
When clearing units from the cache, it simply removed the oldest units from the cache. It is possible that a CachedPage still holds a reference to the released unit. Since the units are consistently referred to with shared_ptrs, the actual memory will not be released until the last page is destroyed. This does, however, allow duplicate units -- one that the cache knows about, and one that a lingering CachedPage references.
Definition at line 39 of file PageCache.h.
| typedef std::list<CachedPage::UnitPtr> PageCache::UnitList |
An STL list of PagePtr.
This list is provided in such a fashion so that calling std::list<UnitPtr>::erase() on an iterator will also delete the CacheUnit properly if it is the last reference.
Definition at line 75 of file PageCache.h.
| PageCache::PageCache | ( | const size_t | maxCacheSize = 20000000 |
) |
Creates a thread-safe LRU PageCache.
| maxCacheSize | The maximum size of the cache in bytes. |
| PageCache::~PageCache | ( | ) |
Destroys the thread-safe LRU PageCache.
| CachedPage::UnitPtr PageCache::getUnit | ( | DataRequest * | pOriginalRequest, | |
| DimensionDescriptor | startRow, | |||
| DimensionDescriptor | startBand | |||
| ) |
Fetches a unit from the cache.
See RasterPager::getPage() for details on the parameters.
| void PageCache::initialize | ( | int | bytesPerBand, | |
| int | columnCount, | |||
| int | bandCount | |||
| ) |
Initializes member variables of the cache & resets hit/miss counts.
This must be done after construction of the cache.
| bytesPerBand | The number of bytes each element takes up. Requires the value contained by RasterDataDescriptor::getBytesPerElement(). | |
| columnCount | The number of columns in file on disk. | |
| bandCount | The number of bands in the file on disk. |
| CachedPage* PageCache::createPage | ( | CachedPage::UnitPtr | pUnit, | |
| InterleaveFormatType | requestedFormat, | |||
| DimensionDescriptor | startRow, | |||
| DimensionDescriptor | startColumn, | |||
| DimensionDescriptor | startBand | |||
| ) |
Create a CachedPage for the given cache unit.
| pUnit | The unit to create the page for. | |
| requestedFormat | The format of the page provided. | |
| startRow | The desired row. | |
| startColumn | The desired column. | |
| startBand | The desired band. |
| void PageCache::enforceCacheSize | ( | ) | [protected] |
const size_t PageCache::MAX_CACHE_SIZE [protected] |
Definition at line 113 of file PageCache.h.
UnitList PageCache::mUnits [protected] |
Definition at line 114 of file PageCache.h.
std::string PageCache::mFilename [protected] |
Definition at line 115 of file PageCache.h.
size_t PageCache::mCacheSize [protected] |
Definition at line 116 of file PageCache.h.
int PageCache::mBytesPerBand [protected] |
Definition at line 117 of file PageCache.h.
int PageCache::mColumnCount [protected] |
Definition at line 118 of file PageCache.h.
int PageCache::mBandCount [protected] |
Definition at line 119 of file PageCache.h.