#include <DelegatingCacheAccessor.h>
Inheritance diagram for DelegatingCacheAccessor:
Public Member Functions | |
DelegatingCacheAccessor (SharedCacheAccessor pDelegate) | |
Constructor. | |
virtual CachePage * | lockPage (BlockId blockId, LockMode lockMode, bool readIfUnmapped=true, MappedPageListener *pMappedPageListener=NULL, TxnId txnId=IMPLICIT_TXN_ID) |
Locks a page into memory with the specified concurrency mode. | |
virtual void | unlockPage (CachePage &page, LockMode lockMode, TxnId txnId=IMPLICIT_TXN_ID) |
Releases lock held on page. | |
virtual void | discardPage (BlockId blockId) |
Unmaps a page from the cache if already mapped, discarding its contents if dirty. | |
virtual bool | prefetchPage (BlockId blockId, MappedPageListener *pMappedPageListener=NULL) |
Hints that a page should be prefetched in preparation for a future lock request. | |
virtual void | prefetchBatch (BlockId blockId, uint nPages, MappedPageListener *pMappedPageListener=NULL) |
Hints that a contiguous run of pages should be prefetched. | |
virtual void | flushPage (CachePage &page, bool async) |
Forces the contents of a dirty page to its mapped location. | |
virtual void | nicePage (CachePage &page) |
Marks a page as nice, indicating that it is very unlikely the page's mapping will be needed again any time soon, so it is a good candidate for victimization. | |
virtual SharedCache | getCache () |
| |
virtual uint | getMaxLockedPages () |
| |
virtual void | setMaxLockedPages (uint nPages) |
Sets the page lock quota on this accessor. | |
virtual void | setTxnId (TxnId txnId) |
Sets a default TxnId to use for locking pages (to be used when IMPLICIT_TXN_ID is specified). | |
virtual TxnId | getTxnId () const |
| |
virtual void | getPrefetchParams (uint &prefetchPagesMax, uint &prefetchThrottleRate) |
Retrieves the current pre-fetch caching parameters that determine how many pages should be pre-fetched and how often the pre-fetches should occur. | |
Private Attributes | |
SharedCacheAccessor | pDelegate |
Definition at line 36 of file DelegatingCacheAccessor.h.
DelegatingCacheAccessor::DelegatingCacheAccessor | ( | SharedCacheAccessor | pDelegate | ) | [explicit] |
Constructor.
pDelegate | the underlying CacheAccessor |
Definition at line 29 of file DelegatingCacheAccessor.cpp.
00031 : pDelegate(pDelegateInit) 00032 { 00033 }
CachePage * DelegatingCacheAccessor::lockPage | ( | BlockId | blockId, | |
LockMode | lockMode, | |||
bool | readIfUnmapped = true , |
|||
MappedPageListener * | pMappedPageListener = NULL , |
|||
TxnId | txnId = IMPLICIT_TXN_ID | |||
) | [virtual] |
Locks a page into memory with the specified concurrency mode.
When the page contents are no longer needed, the caller must invoke the unlockPage() method with the same concurrency mode to release it. If the desired page is already locked by another thread with an incompatible concurrency mode, blocks until the page becomes available (unless the lock mode is of the NoWait variety, in which case returns NULL immediately). Note that NoWait locking only applies to lock contention, not I/O, so if an unmapped page is locked in NoWait mode, blocks until the read completes.
The device referenced by the requested blockId must already be registered with the cache and must remain registered for the duration of the lock.
Notes on concurrency modes:
blockId | the BlockId of the page to be locked | |
lockMode | the desired concurrency mode | |
readIfUnmapped | if true (the default) the page data is read as part of mapping; if false, the page data is left invalid until first write (used when allocating a new block with invalid contents) | |
pMappedPageListener | optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping | |
txnId | optional TxnId to associate with lock; default is IMPLICIT_TXN_ID, which uses current thread ID as an implicit TxnId |
Implements CacheAccessor.
Reimplemented in QuotaCacheAccessor, and TransactionalCacheAccessor.
Definition at line 35 of file DelegatingCacheAccessor.cpp.
References pDelegate.
Referenced by TransactionalCacheAccessor::lockPage().
00041 { 00042 return pDelegate->lockPage( 00043 blockId,lockMode,readIfUnmapped,pMappedPageListener,txnId); 00044 }
void DelegatingCacheAccessor::unlockPage | ( | CachePage & | page, | |
LockMode | lockMode, | |||
TxnId | txnId = IMPLICIT_TXN_ID | |||
) | [virtual] |
Releases lock held on page.
page | the page to be unlocked | |
lockMode | must correspond to value passed to Cache::lockPage; however, for pages locked with NOWAIT, the equivalent unlock type should be normal (e.g. LOCKMODE_S instead of LOCKMODE_S_NOWAIT) | |
txnId | must correspond to value passed to Cache::lockPage |
Implements CacheAccessor.
Reimplemented in QuotaCacheAccessor, and TransactionalCacheAccessor.
Definition at line 46 of file DelegatingCacheAccessor.cpp.
References pDelegate.
Referenced by TransactionalCacheAccessor::unlockPage().
00050 { 00051 pDelegate->unlockPage(page,lockMode,txnId); 00052 }
void DelegatingCacheAccessor::discardPage | ( | BlockId | blockId | ) | [virtual] |
Unmaps a page from the cache if already mapped, discarding its contents if dirty.
The caller must ensure that no other thread has the page locked.
blockId | the BlockId of the page to be discarded |
Implements CacheAccessor.
Definition at line 54 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00056 { 00057 pDelegate->discardPage(blockId); 00058 }
bool DelegatingCacheAccessor::prefetchPage | ( | BlockId | blockId, | |
MappedPageListener * | pMappedPageListener = NULL | |||
) | [virtual] |
Hints that a page should be prefetched in preparation for a future lock request.
blockId | the BlockId of the page to be prefetched | |
pMappedPageListener | optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping |
Implements CacheAccessor.
Definition at line 60 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00063 { 00064 return pDelegate->prefetchPage(blockId,pMappedPageListener); 00065 }
void DelegatingCacheAccessor::prefetchBatch | ( | BlockId | blockId, | |
uint | nPages, | |||
MappedPageListener * | pMappedPageListener = NULL | |||
) | [virtual] |
Hints that a contiguous run of pages should be prefetched.
blockId | the BlockId of the first page to be prefetched; more will be prefetched depending on the configured batch size | |
nPages | number of pages in batch | |
pMappedPageListener | optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping |
Implements CacheAccessor.
Definition at line 67 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00070 { 00071 pDelegate->prefetchBatch(blockId,nPages,pMappedPageListener); 00072 }
void DelegatingCacheAccessor::flushPage | ( | CachePage & | page, | |
bool | async | |||
) | [virtual] |
Forces the contents of a dirty page to its mapped location.
Page must already be locked in exclusive mode. For an asynchronous flush, the caller must ensure that the page contents remain unchanged until the flush completes.
page | the page to be flushed | |
async | true to schedle async write and return immediately; false to wait for write to complete |
Implements CacheAccessor.
Definition at line 74 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00075 { 00076 pDelegate->flushPage(page,async); 00077 }
void DelegatingCacheAccessor::nicePage | ( | CachePage & | page | ) | [virtual] |
Marks a page as nice, indicating that it is very unlikely the page's mapping will be needed again any time soon, so it is a good candidate for victimization.
page | the page to be marked |
Implements CacheAccessor.
Definition at line 79 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00080 { 00081 pDelegate->nicePage(page); 00082 }
SharedCache DelegatingCacheAccessor::getCache | ( | ) | [virtual] |
Implements CacheAccessor.
Definition at line 84 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00085 { 00086 return pDelegate->getCache(); 00087 }
uint DelegatingCacheAccessor::getMaxLockedPages | ( | ) | [virtual] |
Implements CacheAccessor.
Reimplemented in QuotaCacheAccessor.
Definition at line 89 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00090 { 00091 return pDelegate->getMaxLockedPages(); 00092 }
void DelegatingCacheAccessor::setMaxLockedPages | ( | uint | nPages | ) | [virtual] |
Sets the page lock quota on this accessor.
Ignored for accessor implementations that don't support quotas.
nPages | new quota |
Implements CacheAccessor.
Reimplemented in QuotaCacheAccessor.
Definition at line 94 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00095 { 00096 pDelegate->setMaxLockedPages(nPages); 00097 }
void DelegatingCacheAccessor::setTxnId | ( | TxnId | txnId | ) | [virtual] |
Sets a default TxnId to use for locking pages (to be used when IMPLICIT_TXN_ID is specified).
Not all CacheAccessor implementations support this behavior.
txnId | new default txn ID |
Implements CacheAccessor.
Reimplemented in TransactionalCacheAccessor.
Definition at line 104 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00105 { 00106 pDelegate->setTxnId(txnId); 00107 }
TxnId DelegatingCacheAccessor::getTxnId | ( | ) | const [virtual] |
Implements CacheAccessor.
Reimplemented in TransactionalCacheAccessor.
Definition at line 99 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00100 { 00101 return pDelegate->getTxnId(); 00102 }
void DelegatingCacheAccessor::getPrefetchParams | ( | uint & | prefetchPagesMax, | |
uint & | prefetchThrottleRate | |||
) | [virtual] |
Retrieves the current pre-fetch caching parameters that determine how many pages should be pre-fetched and how often the pre-fetches should occur.
[out] | prefetchPagesMax | max number of outstanding pre-fetch pages |
[out] | prefetchThrottleRate | the number of successful pre-fetches that have to occur before the pre-fetch rate is throttled back up, in the event that it has been throttled down due to rejected requests |
Implements CacheAccessor.
Definition at line 109 of file DelegatingCacheAccessor.cpp.
References pDelegate.
00112 { 00113 pDelegate->getPrefetchParams(prefetchPagesMax, prefetchThrottleRate); 00114 }
Definition at line 38 of file DelegatingCacheAccessor.h.
Referenced by discardPage(), flushPage(), getCache(), getMaxLockedPages(), getPrefetchParams(), getTxnId(), lockPage(), nicePage(), prefetchBatch(), prefetchPage(), setMaxLockedPages(), setTxnId(), and unlockPage().