#include <RandomVictimPolicy.h>
| Public Types | |
| typedef NullMutexGuard | SharedGuard | 
| typedef NullMutexGuard | ExclusiveGuard | 
| typedef PageIterator | DirtyPageIterator | 
| Public Member Functions | |
| RandomVictimPolicy () | |
| RandomVictimPolicy (const CacheParams ¶ms) | |
| void | setAllocatedPageCount (uint nCachePages) | 
| void | registerPage (PageT &page) | 
| void | unregisterPage (PageT &) | 
| void | notifyPageAccess (PageT &, bool) | 
| void | notifyPageNice (PageT &) | 
| void | notifyPageMap (PageT &, bool) | 
| void | notifyPageUnmap (PageT &, bool) | 
| void | notifyPageUnpin (PageT &page) | 
| void | notifyPageDirty (PageT &page) | 
| void | notifyPageClean (PageT &page) | 
| void | notifyPageDiscard (BlockId blockId) | 
| NullMutex & | getMutex () | 
| std::pair< PageIterator, PageIterator > | getVictimRange () | 
| std::pair< DirtyPageIterator, DirtyPageIterator > | getDirtyVictimRange () | 
| Private Attributes | |
| NullMutex | nullMutex | 
| Use a null mutex to dummy out all locking requested by the cache. | |
| std::vector< PageT * > | pages | 
| Array of registered pages. | |
| std::subtractive_rng | randomNumberGenerator | 
| Friends | |
| class | PageIterator | 
| Classes | |
| class | PageIterator | 
It is a model for the VictimPolicy concept. See LRUVictimPolicy for general information on VictimPolicy models.
RandomVictimPolicy is intended mostly as a straw-man for benchmarking purposes. However, its simplicity (no synchronization required) could make it a reasonable choice for very large data sets accessed with little locality of reference. Note that it's really not very random at the moment. TODO: improve randomness by occasionally permuting the pages array; but this could require synchronization.
Definition at line 47 of file RandomVictimPolicy.h.
| typedef NullMutexGuard RandomVictimPolicy< PageT >::SharedGuard | 
Definition at line 65 of file RandomVictimPolicy.h.
| typedef NullMutexGuard RandomVictimPolicy< PageT >::ExclusiveGuard | 
Definition at line 66 of file RandomVictimPolicy.h.
| typedef PageIterator RandomVictimPolicy< PageT >::DirtyPageIterator | 
Definition at line 115 of file RandomVictimPolicy.h.
| RandomVictimPolicy< PageT >::RandomVictimPolicy | ( | ) |  [inline] | 
| RandomVictimPolicy< PageT >::RandomVictimPolicy | ( | const CacheParams & | params | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::setAllocatedPageCount | ( | uint | nCachePages | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::registerPage | ( | PageT & | page | ) |  [inline] | 
Definition at line 129 of file RandomVictimPolicy.h.
References RandomVictimPolicy< PageT >::pages.
00130 { 00131 pages.push_back(&page); 00132 }
| void RandomVictimPolicy< PageT >::unregisterPage | ( | PageT & | ) |  [inline] | 
Definition at line 134 of file RandomVictimPolicy.h.
00135 { 00136 // TODO: zfong 1/8/08 - Should remove the page from the pages vector. 00137 // Otherwise, unallocated pages will be returned by getVictimRange(). 00138 }
| void RandomVictimPolicy< PageT >::notifyPageAccess | ( | PageT & | , | |
| bool | ||||
| ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageNice | ( | PageT & | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageMap | ( | PageT & | , | |
| bool | ||||
| ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageUnmap | ( | PageT & | , | |
| bool | ||||
| ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageUnpin | ( | PageT & | page | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageDirty | ( | PageT & | page | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageClean | ( | PageT & | page | ) |  [inline] | 
| void RandomVictimPolicy< PageT >::notifyPageDiscard | ( | BlockId | blockId | ) |  [inline] | 
| NullMutex& RandomVictimPolicy< PageT >::getMutex | ( | ) |  [inline] | 
Definition at line 172 of file RandomVictimPolicy.h.
References RandomVictimPolicy< PageT >::nullMutex.
00173 { 00174 return nullMutex; 00175 }
| std::pair<PageIterator,PageIterator> RandomVictimPolicy< PageT >::getVictimRange | ( | ) |  [inline] | 
Definition at line 177 of file RandomVictimPolicy.h.
References RandomVictimPolicy< PageT >::PageIterator, RandomVictimPolicy< PageT >::pages, and RandomVictimPolicy< PageT >::randomNumberGenerator.
Referenced by RandomVictimPolicy< PageT >::getDirtyVictimRange().
00178 { 00179 uint iPage = randomNumberGenerator(pages.size()); 00180 uint iPageEnd = iPage ? iPage-1 : pages.size(); 00181 return std::pair<PageIterator,PageIterator>( 00182 PageIterator(*this,iPage), 00183 PageIterator(*this,iPageEnd)); 00184 }
| std::pair<DirtyPageIterator,DirtyPageIterator> RandomVictimPolicy< PageT >::getDirtyVictimRange | ( | ) |  [inline] | 
Definition at line 186 of file RandomVictimPolicy.h.
References RandomVictimPolicy< PageT >::getVictimRange().
00187 { 00188 return 00189 static_cast<std::pair<DirtyPageIterator,DirtyPageIterator> >( 00190 getVictimRange()); 00191 }
| friend class PageIterator  [friend] | 
Definition at line 61 of file RandomVictimPolicy.h.
Referenced by RandomVictimPolicy< PageT >::getVictimRange().
| NullMutex RandomVictimPolicy< PageT >::nullMutex  [private] | 
Use a null mutex to dummy out all locking requested by the cache.
Definition at line 52 of file RandomVictimPolicy.h.
Referenced by RandomVictimPolicy< PageT >::getMutex().
| std::vector<PageT *> RandomVictimPolicy< PageT >::pages  [private] | 
Array of registered pages.
Definition at line 57 of file RandomVictimPolicy.h.
Referenced by RandomVictimPolicy< PageT >::PageIterator::getCurrent(), RandomVictimPolicy< PageT >::getVictimRange(), RandomVictimPolicy< PageT >::PageIterator::operator++(), and RandomVictimPolicy< PageT >::registerPage().
| std::subtractive_rng RandomVictimPolicy< PageT >::randomNumberGenerator  [private] | 
Definition at line 59 of file RandomVictimPolicy.h.
Referenced by RandomVictimPolicy< PageT >::getVictimRange().
 1.5.1
 1.5.1