00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/segment/DynamicDelegatingSegment.h"
00026
00027 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/segment/DynamicDelegatingSegment.cpp#8 $");
00028
00029 DynamicDelegatingSegment::DynamicDelegatingSegment(
00030 WeakSegment delegatingSegment)
00031 : Segment(SharedSegment(delegatingSegment)->getCache()),
00032 delegateSegment(delegatingSegment)
00033 {
00034 setUsablePageSize(SharedSegment(delegateSegment)->getUsablePageSize());
00035 }
00036
00037 DynamicDelegatingSegment::~DynamicDelegatingSegment()
00038 {
00039 }
00040
00041 void DynamicDelegatingSegment::closeImpl()
00042 {
00043 Segment::closeImpl();
00044 delegateSegment.reset();
00045 }
00046
00047 BlockNum DynamicDelegatingSegment::getAllocatedSizeInPages()
00048 {
00049 SharedSegment pDelegateSegment = delegateSegment.lock();
00050 return pDelegateSegment->getAllocatedSizeInPages();
00051 }
00052
00053 BlockNum DynamicDelegatingSegment::getNumPagesOccupiedHighWater()
00054 {
00055 SharedSegment pDelegateSegment = delegateSegment.lock();
00056 return pDelegateSegment->getNumPagesOccupiedHighWater();
00057 }
00058
00059 BlockNum DynamicDelegatingSegment::getNumPagesExtended()
00060 {
00061 SharedSegment pDelegateSegment = delegateSegment.lock();
00062 return pDelegateSegment->getNumPagesExtended();
00063 }
00064
00065 PageId DynamicDelegatingSegment::getPageSuccessor(PageId pageId)
00066 {
00067 SharedSegment pDelegateSegment = delegateSegment.lock();
00068 return pDelegateSegment->getPageSuccessor(pageId);
00069 }
00070
00071 void DynamicDelegatingSegment::setPageSuccessor(
00072 PageId pageId,
00073 PageId successorId)
00074 {
00075 SharedSegment pDelegateSegment = delegateSegment.lock();
00076 pDelegateSegment->setPageSuccessor(pageId,successorId);
00077 }
00078
00079 BlockId DynamicDelegatingSegment::translatePageId(PageId pageId)
00080 {
00081 SharedSegment pDelegateSegment = delegateSegment.lock();
00082 return pDelegateSegment->translatePageId(pageId);
00083 }
00084
00085 PageId DynamicDelegatingSegment::translateBlockId(BlockId blockId)
00086 {
00087 SharedSegment pDelegateSegment = delegateSegment.lock();
00088 return pDelegateSegment->translateBlockId(blockId);
00089 }
00090
00091 PageId DynamicDelegatingSegment::allocatePageId(PageOwnerId ownerId)
00092 {
00093 SharedSegment pDelegateSegment = delegateSegment.lock();
00094 return pDelegateSegment->allocatePageId(ownerId);
00095 }
00096
00097 bool DynamicDelegatingSegment::ensureAllocatedSize(BlockNum nPages)
00098 {
00099 SharedSegment pDelegateSegment = delegateSegment.lock();
00100 return pDelegateSegment->ensureAllocatedSize(nPages);
00101 }
00102
00103 void DynamicDelegatingSegment::deallocatePageRange(
00104 PageId startPageId,
00105 PageId endPageId)
00106 {
00107 SharedSegment pDelegateSegment = delegateSegment.lock();
00108 pDelegateSegment->deallocatePageRange(startPageId,endPageId);
00109 }
00110
00111 bool DynamicDelegatingSegment::isPageIdAllocated(PageId pageId)
00112 {
00113 SharedSegment pDelegateSegment = delegateSegment.lock();
00114 return pDelegateSegment->isPageIdAllocated(pageId);
00115 }
00116
00117 Segment::AllocationOrder DynamicDelegatingSegment::getAllocationOrder() const
00118 {
00119 SharedSegment pDelegateSegment = delegateSegment.lock();
00120 return pDelegateSegment->getAllocationOrder();
00121 }
00122
00123 void DynamicDelegatingSegment::notifyPageMap(CachePage &page)
00124 {
00125 SharedSegment pDelegateSegment = delegateSegment.lock();
00126 pDelegateSegment->notifyPageMap(page);
00127 }
00128
00129 void DynamicDelegatingSegment::notifyPageUnmap(CachePage &page)
00130 {
00131 SharedSegment pDelegateSegment = delegateSegment.lock();
00132 pDelegateSegment->notifyPageUnmap(page);
00133 }
00134
00135 void DynamicDelegatingSegment::notifyAfterPageRead(CachePage &page)
00136 {
00137 SharedSegment pDelegateSegment = delegateSegment.lock();
00138 pDelegateSegment->notifyAfterPageRead(page);
00139 }
00140
00141 void DynamicDelegatingSegment::notifyPageDirty(CachePage &page,bool bDataValid)
00142 {
00143 SharedSegment pDelegateSegment = delegateSegment.lock();
00144 pDelegateSegment->notifyPageDirty(page,bDataValid);
00145 }
00146
00147 void DynamicDelegatingSegment::notifyBeforePageFlush(CachePage &page)
00148 {
00149 SharedSegment pDelegateSegment = delegateSegment.lock();
00150 pDelegateSegment->notifyBeforePageFlush(page);
00151 }
00152
00153 void DynamicDelegatingSegment::notifyAfterPageFlush(CachePage &page)
00154 {
00155 SharedSegment pDelegateSegment = delegateSegment.lock();
00156 pDelegateSegment->notifyAfterPageFlush(page);
00157 }
00158
00159 bool DynamicDelegatingSegment::canFlushPage(CachePage &page)
00160 {
00161 SharedSegment pDelegateSegment = delegateSegment.lock();
00162 return pDelegateSegment->canFlushPage(page);
00163 }
00164
00165 void DynamicDelegatingSegment::delegatedCheckpoint(
00166 Segment &delegatingSegment,CheckpointType checkpointType)
00167 {
00168
00169
00170
00171
00172 SharedSegment pDelegateSegment = delegateSegment.lock();
00173 if (pDelegateSegment) {
00174 pDelegateSegment->delegatedCheckpoint(
00175 delegatingSegment,
00176 checkpointType);
00177 }
00178 }
00179
00180 bool DynamicDelegatingSegment::isWriteVersioned()
00181 {
00182 SharedSegment pDelegateSegment = delegateSegment.lock();
00183 return pDelegateSegment->isWriteVersioned();
00184 }
00185
00186 PageId DynamicDelegatingSegment::updatePage(
00187 PageId pageId,
00188 bool needsTranslation)
00189 {
00190 SharedSegment pDelegateSegment = delegateSegment.lock();
00191 return pDelegateSegment->updatePage(pageId, needsTranslation);
00192 }
00193
00194 MappedPageListener *DynamicDelegatingSegment::getMappedPageListener(
00195 BlockId blockId)
00196 {
00197
00198
00199 SharedSegment pDelegateSegment = delegateSegment.lock();
00200 return pDelegateSegment->getMappedPageListener(blockId);
00201 }
00202
00203 void DynamicDelegatingSegment::setDelegatingSegment(
00204 WeakSegment delegatingSegment)
00205 {
00206 delegateSegment = delegatingSegment;
00207 }
00208
00209 SharedSegment DynamicDelegatingSegment::getDelegateSegment()
00210 {
00211 return delegateSegment.lock();
00212 }
00213
00214 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/segment/DynamicDelegatingSegment.cpp#8 $");
00215
00216