userlibandfileserver/fileserver/sfile/sf_memory_client.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
   142         ASSERT(0);
   142         ASSERT(0);
   143         }
   143         }
   144 
   144 
   145 	iTouchedRegionFlag = 0;
   145 	iTouchedRegionFlag = 0;
   146 	iReusablePagePool.Close();
   146 	iReusablePagePool.Close();
   147 	iReusablePagePool.Reserve(iReservedRegionMarkInSegs);
   147 	r = iReusablePagePool.Reserve(iReservedRegionMarkInSegs);
   148     if (r != KErrNone)
   148     if (r != KErrNone)
   149         {
   149         {
   150         ASSERT(0);
   150         ASSERT(0);
   151         }
   151         }
   152 	}
   152 	}
   172        	iTouchedRegionFlag += aSegmentCount;
   172        	iTouchedRegionFlag += aSegmentCount;
   173 //       	__PRINT3(_L("!! USED RESERVED SEGS: addr=0x%x, touched=%d, reserved=%d"), addr, iTouchedRegionFlag, iReservedRegionMarkInSegs);
   173 //       	__PRINT3(_L("!! USED RESERVED SEGS: addr=0x%x, touched=%d, reserved=%d"), addr, iTouchedRegionFlag, iReservedRegionMarkInSegs);
   174        	return addr;
   174        	return addr;
   175        	}
   175        	}
   176     
   176     
   177 	// if we have used up reserved region, get new pages from reusable pool first
   177     TBool touchedMore = EFalse;
       
   178 	// if we have touched beyond reserved region, get new pages from reusable pool first
   178     if (iReusablePagePool.Count())
   179     if (iReusablePagePool.Count())
   179     	{
   180     	{
   180 		addr = iReusablePagePool[0];
   181 		addr = iReusablePagePool[0];
   181 		iReusablePagePool.Remove(0);
   182 		iReusablePagePool.Remove(0);
   182 //       	__PRINT2(_L("!! USED REUSABLE POOL SEGS: addr=0x%x, reusable.Count()=%d"), addr, iReusablePagePool.Count());
   183 //       	__PRINT2(_L("!! USED REUSABLE POOL SEGS: addr=0x%x, reusable.Count()=%d"), addr, iReusablePagePool.Count());
   183     	}
   184     	}
   184     // or we grow the touched region flag
   185     // or we grow the touched region flag
   185     else
   186     else
   186     	{
   187     	{
   187     	addr = iBase + (iTouchedRegionFlag << iSegSizeInBytesLog2);
   188     	addr = iBase + (iTouchedRegionFlag << iSegSizeInBytesLog2);
   188     	iTouchedRegionFlag += aSegmentCount;
   189     	touchedMore = ETrue;
   189 //       	__PRINT2(_L("!! GROW TOUCHED SEGS: addr=0x%x, touched=%d"), addr, iTouchedRegionFlag);
   190 //       	__PRINT2(_L("!! GROW TOUCHED SEGS: addr=0x%x, touched=%d"), addr, iTouchedRegionFlag);
   190     	}
   191     	}
   191 	
   192 	
   192     // parameter validation
   193     // parameter validation
   193     ASSERT(((addr - iBase) >> iSegSizeInBytesLog2) + aSegmentCount <= iMaxSizeInSegs);
   194     ASSERT(((addr - iBase) >> iSegSizeInBytesLog2) + aSegmentCount <= iMaxSizeInSegs);
   199 
   200 
   200     TInt r = iManager.AllocateAndLockSegments(addr, aSegmentCount);
   201     TInt r = iManager.AllocateAndLockSegments(addr, aSegmentCount);
   201 	if (r != KErrNone)
   202 	if (r != KErrNone)
   202 		return NULL;
   203 		return NULL;
   203 
   204 
       
   205 	if (touchedMore)
       
   206 	    {
       
   207 	    iTouchedRegionFlag += aSegmentCount;
       
   208 	    }
   204 	return addr;
   209 	return addr;
   205 	}
   210 	}
   206 
   211 
   207 /**
   212 /**
   208 Decommit a set of contiguous segments. 
   213 Decommit a set of contiguous segments.