userlibandfileserver/fileserver/sfile/sf_memory_client.cpp
changeset 201 43365a9b78a3
parent 90 947f0dc9f7a8
child 245 647ab20fee2e
equal deleted inserted replaced
200:73ea206103e6 201:43365a9b78a3
   168        	iTouchedRegionFlag += aSegmentCount;
   168        	iTouchedRegionFlag += aSegmentCount;
   169 //       	__PRINT3(_L("!! USED RESERVED SEGS: addr=0x%x, touched=%d, reserved=%d"), addr, iTouchedRegionFlag, iReservedRegionMarkInSegs);
   169 //       	__PRINT3(_L("!! USED RESERVED SEGS: addr=0x%x, touched=%d, reserved=%d"), addr, iTouchedRegionFlag, iReservedRegionMarkInSegs);
   170        	return addr;
   170        	return addr;
   171        	}
   171        	}
   172     
   172     
   173 	// if we have used up reserved region, get new pages from reusable pool first
   173     TBool touchedMore = EFalse;
       
   174 	// if we have touched beyond reserved region, get new pages from reusable pool first
   174     if (iReusablePagePool.Count())
   175     if (iReusablePagePool.Count())
   175     	{
   176     	{
   176 		addr = iReusablePagePool[0];
   177 		addr = iReusablePagePool[0];
   177 		iReusablePagePool.Remove(0);
   178 		iReusablePagePool.Remove(0);
   178 //       	__PRINT2(_L("!! USED REUSABLE POOL SEGS: addr=0x%x, reusable.Count()=%d"), addr, iReusablePagePool.Count());
   179 //       	__PRINT2(_L("!! USED REUSABLE POOL SEGS: addr=0x%x, reusable.Count()=%d"), addr, iReusablePagePool.Count());
   179     	}
   180     	}
   180     // or we grow the touched region flag
   181     // or we grow the touched region flag
   181     else
   182     else
   182     	{
   183     	{
   183     	addr = iBase + (iTouchedRegionFlag << iSegSizeInBytesLog2);
   184     	addr = iBase + (iTouchedRegionFlag << iSegSizeInBytesLog2);
   184     	iTouchedRegionFlag += aSegmentCount;
   185     	touchedMore = ETrue;
   185 //       	__PRINT2(_L("!! GROW TOUCHED SEGS: addr=0x%x, touched=%d"), addr, iTouchedRegionFlag);
   186 //       	__PRINT2(_L("!! GROW TOUCHED SEGS: addr=0x%x, touched=%d"), addr, iTouchedRegionFlag);
   186     	}
   187     	}
   187 	
   188 	
   188     // parameter validation
   189     // parameter validation
   189     ASSERT(((addr - iBase) >> iSegSizeInBytesLog2) + aSegmentCount <= iMaxSizeInSegs);
   190     ASSERT(((addr - iBase) >> iSegSizeInBytesLog2) + aSegmentCount <= iMaxSizeInSegs);
   195 
   196 
   196     TInt r = iManager.AllocateAndLockSegments(addr, aSegmentCount);
   197     TInt r = iManager.AllocateAndLockSegments(addr, aSegmentCount);
   197 	if (r != KErrNone)
   198 	if (r != KErrNone)
   198 		return NULL;
   199 		return NULL;
   199 
   200 
       
   201 	if (touchedMore)
       
   202 	    {
       
   203 	    iTouchedRegionFlag += aSegmentCount;
       
   204 	    }
   200 	return addr;
   205 	return addr;
   201 	}
   206 	}
   202 
   207 
   203 /**
   208 /**
   204 Decommit a set of contiguous segments. 
   209 Decommit a set of contiguous segments.