Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfile\sf_cache_client.cpp
24 #include <e32std_private.h>
29 #include "sf_cache_man.h"
30 #include "sf_cache_client.h"
31 #include "sf_file_cache_defs.h"
33 // This macro chnages the code so that new cachelines are stolen from the queue (if it is full)
34 // thus reducing the calls to RChunk::Commit
35 #define SYMBIAN_REUSE_STALE_CACHELINES
37 enum TCacheClientFault
39 ECacheClientSegmentNotFound0,
40 ECacheClientSegmentNotFound1,
41 ECacheClientSegmentNotFound2,
42 ECacheClientSegmentNotFound3,
43 ECacheClientSegmentNotFound4,
44 ECacheClientSegmentNotFound5,
45 ECacheClientSegmentNotFound6,
46 ECacheClientSegmentNotFound7,
47 ECacheClientLruInsertFailed,
48 ECacheClientInsertFailed,
49 ECacheClientRemovingBusySegment,
50 ECacheClientRemovingLockedSegment,
51 ECacheClientRemovingDirtySegment,
52 ECacheClientInvalidSegmentCount,
53 ECacheClientAlreadyLocked,
54 ECacheClientSegmentNotLocked,
55 ECacheClientSegmentNotDirty,
56 ECacheClientSegmentAlreadyUnlocked,
57 ECacheClientSegmentBadLockCount,
58 ECacheClientTotalByteCountInvalid,
59 ECacheClientUnexpectedHole,
60 ECacheClientSegmentAlreadyAllocated
64 LOCAL_C void Fault(TCacheClientFault aFault)
66 // Report a fault in the cache client
69 User::Panic(_L("FSCACHECLIENT"), aFault);
73 const TInt KSegmentArrayGranularity = 4;
76 //******************************
78 //******************************
80 CCacheClient* CCacheClient::NewL(CCacheManager& aManager)
82 CCacheClient* client = new(ELeave) CCacheClient(aManager);
84 CleanupStack::PushL(client);
86 CleanupStack::Pop(1, client);
91 void CCacheClient::ConstructL()
93 iCacheLines = new(ELeave) RPointerArray<CCacheManager::TCacheLine>(KSegmentArrayGranularity);
95 iLastCacheLineIndex = -1;
98 CCacheClient::CCacheClient(CCacheManager& aManager) : iManager(aManager)
100 __CACHE_PRINT(_L("CACHECLIENT: CCacheClient()"));
106 Purge() - free all cachelines
107 if aPurgeDirty == ETrue then discard all dirty data
108 E.g. if called from the destructor or following media removal
110 void CCacheClient::Purge(TBool aPurgeDirty)
112 TInt cacheLineCount = iCacheLines->Count();
114 for (n=0; n<cacheLineCount; n++)
116 CCacheManager::TCacheLine& cacheLine = *(*iCacheLines)[n];
119 // Purge any locked and/or dirty cachlines if we still own them
120 // Freeing any locked or dirty pages implies that flushing the file
121 // has failed for some reason (media removal for example).
123 // NB if we own a cacheline and it is "in use" it's an error
124 // NB we need to check if it's locked first and then if we own it
125 // to guard against it being stolen by another thread.
126 if (aPurgeDirty && iManager.DirtyCount(this, cacheLine) != 0 && cacheLine.iClient == this)
129 if (iManager.LockCount(this, cacheLine) != 0)
130 __CACHE_PRINT(_L("CACHECLIENT: purging with locked segments"));
131 if (iManager.DirtyCount(this, cacheLine) != 0)
132 __CACHE_PRINT(_L("CACHECLIENT: purging dirty segments"));
133 __ASSERT_DEBUG(!iManager.InUse(cacheLine), Fault(ECacheClientRemovingBusySegment));
135 if (iManager.DirtyCount(this, cacheLine) != 0)
136 iManager.ClearDirty(this, cacheLine);
137 while (iManager.LockCount(this, cacheLine) != 0)
138 iManager.UnlockCacheLine(this, cacheLine);
141 TBool success = iManager.FreeCacheLine(this, cacheLine);
143 // if (aPurgeDirty == ETrue), then it is an error
144 // if a cacheline could not be freed (because it was locked).
147 __ASSERT_ALWAYS(success, Fault(ECacheClientRemovingLockedSegment));
153 CCacheClient::~CCacheClient()
155 __CACHE_PRINT1(_L("CACHECLIENT: ~CCacheClient() this %08X"), this);
160 iCacheLines->Close();
166 void CCacheClient::SetMaxSegments(TInt aMaxSegments)
168 iMaxBytesCached = aMaxSegments << iManager.SegmentSizeLog2();
172 TInt CCacheClient::SegmentSize()
174 return iManager.SegmentSize();
177 TInt CCacheClient::SegmentSizeLog2()
179 return iManager.SegmentSizeLog2();
182 TInt64 CCacheClient::SegmentSizeMask()
184 return iManager.SegmentSizeMask();
187 TInt CCacheClient::CacheLineSize()
189 return iManager.CacheLineSize();
192 TInt CCacheClient::CacheLineSizeInSegments()
194 return iManager.CacheLineSizeInSegments();
197 TUint8* CCacheClient::FindAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TInt& aFilledSegmentCount, TInt& aLockError, TBool aMakeDirty)
199 TInt maxSegments = Min(aSegmentCount, CacheLineSizeInSegments());
201 aFilledSegmentCount = 0;
203 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
205 aLockError = KErrNone;
210 TInt offset = (TInt) (aPos - cacheLine->iPos);
211 TInt len = CacheLineLen(cacheLine) - offset;
213 TInt segmentSizeLog2 = iManager.SegmentSizeLog2();
215 TInt startSegmentNumber = offset >> segmentSizeLog2;
216 TInt filledCount = iManager.FillCount(this, *cacheLine);
218 // round up to a whole number of segments
219 aSegmentCount = ((len + iManager.SegmentSize() - 1) >> segmentSizeLog2);
220 aSegmentCount = Min(aSegmentCount, maxSegments);
223 aFilledSegmentCount = (filledCount > startSegmentNumber)?filledCount - startSegmentNumber:0;
225 __CACHE_PRINT4(_L("CACHECLIENT: FindAndLockSegments(), Client %08X pos %d addr %08X len %d"),
226 this, I64LOW(cacheLine->iPos), cacheLine->iAddr, CacheLineLen(cacheLine));
229 aLockError = LockSegments(aPos, aSegmentCount, aMakeDirty);
230 if (aLockError != KErrNone)
233 return cacheLine->iAddr + offset;
236 TUint8* CCacheClient::FindSegment(TInt64 aPos)
238 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
243 TInt offset = (TInt) (aPos - cacheLine->iPos);
244 return cacheLine->iAddr + offset;
247 TUint8* CCacheClient::AllocateAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TBool aMakeDirty, TBool aExtendExisting)
249 __ASSERT_DEBUG(aSegmentCount >= 0, Fault(ECacheClientInvalidSegmentCount));
251 TInt segmentSizeLog2 = iManager.SegmentSizeLog2();
252 TInt segmentSize = iManager.SegmentSize();
253 TInt cacheLineSize = iManager.CacheLineSize();
255 aPos = (aPos >> segmentSizeLog2) << segmentSizeLog2;
258 // count number of uncached segments
259 TInt maxSegments = Min(aSegmentCount, CacheLineSizeInSegments());
261 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
262 // This is test code and changes the behaviour so that we always allocate
263 // as large a cacheline as possible, so as to increase the likelihood of "holes"
264 if (iManager.AllocateMaxSegments())
266 maxSegments = cacheLineSize >> segmentSizeLog2;
270 // make sure requested range doesn't overlap with an existing cacheline -
271 // if it does, shrink requested length down
272 TInt64 endPos = aPos + (maxSegments << segmentSizeLog2);
273 TInt cacheLineCount = iCacheLines->Count();
274 for (TInt index=0; index < cacheLineCount; index++)
276 const CCacheManager::TCacheLine* cacheLine = (*iCacheLines)[index];
277 TInt64 startPos = cacheLine->iPos;
278 if (cacheLine->iClient == this && startPos >= aPos && startPos < endPos)
280 endPos = cacheLine->iPos;
283 TInt segmentCount = (TInt) ((endPos - aPos) >> segmentSizeLog2);
285 __ASSERT_DEBUG(segmentCount > 0, Fault(ECacheClientSegmentAlreadyAllocated));
287 aSegmentCount = Min(segmentCount, aSegmentCount);
289 iLastCacheLineIndex = -1;
291 TUint8* segmentAddr = NULL;
293 __CACHE_PRINT2(_L("CACHECLIENT: AllocateAndLockSegments(%ld, %d)"), aPos, segmentCount);
295 // can we extend an existing cacheline ? (this saves wasting virtual memory)
296 // NB if we're about the make the new segment(s) dirty, only extend if last segment in existing
297 // cacheline is dirty, otherwise we'll end up unnecessarily marking lots of clean segments as dirty
300 TInt64 posLastSegment = aPos - segmentSize;
301 const CCacheManager::TCacheLine* cacheLineOld;
303 if ((posLastSegment >= 0) && ((cacheLineOld = FindCacheLine(posLastSegment)) != NULL))
305 TInt prevSegmentNumber = StartSegment(cacheLineOld, posLastSegment);
306 TInt fillCountOld = iManager.FillCount(this, *cacheLineOld);
307 TInt fillCountNew = segmentCount + prevSegmentNumber+1; // fillCountOld;
308 if (prevSegmentNumber+1 == fillCountOld &&
309 fillCountNew <= (cacheLineSize >> segmentSizeLog2) &&
310 (!aMakeDirty || (prevSegmentNumber+1 == cacheLineOld->iDirtySegments))
313 __CACHE_PRINT(_L("CACHE: extending cacheline"));
315 segmentAddr = cacheLineOld->iAddr + (TInt) (aPos - cacheLineOld->iPos);
317 // Lock the cacheline and then try to extend it
318 r = LockSegments(cacheLineOld->iPos, cacheLineOld->iAllocatedSegments, ETrue);
321 r = iManager.ExtendCacheLine(this, *cacheLineOld, fillCountNew);
322 //RDebug::Print(_L("GROW addr %08X, prevSegmentNumber %d, fillCount %d, fillCountNew %d, r %d\n"),
323 // cacheLineOld->iAddr, prevSegmentNumber, fillCountOld, fillCountNew, r);
326 // If we've exceeded max, use LRU queue to discard old cachelines
327 RemoveLru(cacheLineOld);
330 __CACHE_PRINT(_L("LockSegments FAIL"));
331 UnlockSegments(posLastSegment);
337 // reserve space in the segment array & LRU queue so we don't have to
338 // worry about failing to append
339 if (iCacheLines->Reserve(1) != KErrNone)
342 const CCacheManager::TCacheLine* cacheLineNew = NULL;
343 TBool reUsedCacheLineGrown = EFalse;
345 #ifdef SYMBIAN_REUSE_STALE_CACHELINES
346 // try to re-use an old cacheline if possible to avoid having to commit a new one
347 // as this involves calling RChunk::Commit() which takes some time....
348 TInt lenNewCacheLine = segmentCount << segmentSizeLog2;
349 TInt totalBytesCached = CachedBytes() + lenNewCacheLine;
351 cacheLineCount = iCacheLines->Count();
352 if (cacheLineCount > 0)
354 const CCacheManager::TCacheLine* cacheLineOld = (*iCacheLines)[cacheLineCount - 1];
355 TInt lenOldCacheLine = cacheLineOld->iFilledSegments << segmentSizeLog2;
356 reUsedCacheLineGrown = segmentCount > cacheLineOld->iAllocatedSegments;
357 if (totalBytesCached + lenNewCacheLine - lenOldCacheLine > iMaxBytesCached &&
358 cacheLineOld->iClient == this &&
359 cacheLineOld->iLockCount == 0)
361 if (iManager.ReAllocateAndLockCacheLine(this, aPos, *cacheLineOld, segmentCount) == KErrNone)
363 cacheLineNew = cacheLineOld;
367 #endif // SYMBIAN_REUSE_STALE_CACHELINES
368 TBool reUsingCacheline = cacheLineNew ? (TBool)ETrue:(TBool)EFalse;
370 // Request a free segment from cache manager
371 if (reUsingCacheline)
373 iCacheLines->Remove(cacheLineCount-1);
377 TInt r = iManager.AllocateAndLockCacheLine(this, aPos, cacheLineNew, segmentCount);
380 __CACHE_PRINT1(_L("CACHECLIENT: AllocateSegment() failed r %d"), r);
383 // check the address isn't already in the iCacheLines -
384 // this can happen if it was stolen from us and we then steal it back
385 TInt indexDup = iCacheLines->Find(cacheLineNew);
386 if (indexDup != KErrNotFound)
387 iCacheLines->Remove(indexDup);
391 segmentAddr = cacheLineNew->iAddr;
393 // Add to top of LRU queue
394 TInt r = iCacheLines->Insert(cacheLineNew, 0);
395 __ASSERT_ALWAYS(r == KErrNone, Fault(ECacheClientInsertFailed));
397 __CACHE_PRINT4(_L("CACHECLIENT: AllocateAndLockSegments(), Client %08X pos %d addr %08X len %d"),
398 this, I64LOW(cacheLineNew->iPos), cacheLineNew->iAddr, CacheLineLen(cacheLineNew));
400 // assume LRU in use ...
401 iLastCacheLineIndex = 0;
403 if (!reUsingCacheline || reUsedCacheLineGrown)
404 RemoveLru(cacheLineNew);
411 TInt CCacheClient::StartSegment(const CCacheManager::TCacheLine* aCacheLine, TInt64 aPos)
413 TInt offset = (TInt) (aPos - aCacheLine->iPos);
414 return offset >> iManager.SegmentSizeLog2();
417 TInt CCacheClient::CacheLineLen(const CCacheManager::TCacheLine* aCacheLine)
419 return aCacheLine->iAllocatedSegments << iManager.SegmentSizeLog2();
423 void CCacheClient::MarkSegmentsAsFilled(TInt64 aPos, TInt aSegmentCount)
425 __CACHE_PRINT2(_L("CACHECLIENT: Mark Filled Segments(%ld, %d)"), aPos, aSegmentCount);
427 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
429 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound0));
431 iManager.SetFilled(this, *cacheLine, StartSegment(cacheLine, aPos) + aSegmentCount);
434 void CCacheClient::MarkSegmentsAsDirty(TInt64 aPos, TInt aSegmentCount)
436 __CACHE_PRINT2(_L("CACHECLIENT: Mark Dirty Segments(%ld, %d)"), aPos, aSegmentCount);
438 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
440 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound1));
442 iManager.SetDirty(this, *cacheLine, StartSegment(cacheLine, aPos) + aSegmentCount);
445 TInt CCacheClient::FindFirstDirtySegment(TInt64& aPos, TUint8*& aAddr)
447 TInt cacheLineCount = iCacheLines->Count();
450 TInt segmentCount = 0;
451 for (TInt index = 0; index< cacheLineCount; index++)
453 CCacheManager::TCacheLine& cacheLine = *(*iCacheLines)[index];
455 TInt dirtyCount = iManager.DirtyCount(this, cacheLine);
456 if ((dirtyCount > 0 && cacheLine.iPos < aPos))
458 aPos = cacheLine.iPos;
459 aAddr = cacheLine.iAddr;
460 segmentCount = dirtyCount;
468 void CCacheClient::MarkSegmentsAsClean(TInt64 aPos)
470 __CACHE_PRINT1(_L("CACHECLIENT: MarkSegmentsAsClean(%d)"), I64LOW(aPos));
472 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
474 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound2));
476 // this sets the dirty count to zero, unlocks the cacheline and
477 // marks all the dirty pages as filled
478 iManager.ClearDirty(this, *cacheLine);
480 RemoveLru(cacheLine);
484 void CCacheClient::RemoveEmptySegments(const CCacheManager::TCacheLine* aCacheLine)
486 iManager.RemoveEmptySegments(this, *aCacheLine);
489 TInt CCacheClient::LockSegments(TInt64 aPos, TInt aSegmentCount, TBool aMakeDirty)
491 __CACHE_PRINT1(_L("CACHECLIENT: LockCacheLine(%d, %d)"), I64LOW(aPos));
493 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
495 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound3));
498 TInt startSegmentNumber = StartSegment(cacheLine, aPos);
502 lockError = iManager.LockCacheLine(this, *cacheLine, 0, cacheLine->iAllocatedSegments);
504 lockError = iManager.LockCacheLine(this, *cacheLine, startSegmentNumber, aSegmentCount);
506 if (lockError == KErrInUse)
510 else if (lockError != KErrNone)
512 RemoveCacheLine(cacheLine);
516 // Check for "holes".i.e. empty segments before this one.
517 // If found, discard the empty segments and return KErrNotFound
518 TInt filledCount = iManager.FillCount(this, *cacheLine);
519 if (startSegmentNumber > filledCount)
521 __CACHE_PRINT(_L("CACHE: found hole"));
522 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
523 iManager.Stats().iHoleCount++;
527 RemoveEmptySegments(cacheLine);
528 iManager.UnlockCacheLine(this, *cacheLine);
529 if (CacheLineLen(cacheLine) == 0)
530 FreeCacheLine(cacheLine);
534 // Move this entry to top of LRU queue
535 iCacheLines->Remove(iLastCacheLineIndex);
539 iCacheLines->Insert(cacheLine, 0);
540 __ASSERT_DEBUG(r == KErrNone, Fault(ECacheClientLruInsertFailed));
541 iLastCacheLineIndex = 0;
551 void CCacheClient::UnlockSegments(TInt64 aPos)
553 __CACHE_PRINT1(_L("CACHECLIENT: UnlockSegments(%d, %d)"), I64LOW(aPos));
555 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
557 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound4));
559 iManager.UnlockCacheLine(this, *cacheLine);
563 TInt CCacheClient::FindCacheLineIndex(TInt64 aPos)
565 TInt cacheLineCount = iCacheLines->Count();
567 if (iLastCacheLineIndex != -1 && iLastCacheLineIndex < cacheLineCount)
569 const CCacheManager::TCacheLine* cacheLine = (*iCacheLines)[iLastCacheLineIndex];
571 if (cacheLine->iClient == this &&
572 aPos >= cacheLine->iPos &&
573 aPos < cacheLine->iPos+CacheLineLen(cacheLine))
574 return iLastCacheLineIndex;
577 for (TInt index=0; index < cacheLineCount; index++)
579 const CCacheManager::TCacheLine* cacheLine = (*iCacheLines)[index];
581 if (cacheLine->iClient == this &&
582 aPos >= cacheLine->iPos &&
583 (aPos < cacheLine->iPos+CacheLineLen(cacheLine)))
585 iLastCacheLineIndex = index;
593 const CCacheManager::TCacheLine* CCacheClient::FindCacheLine(TInt64 aPos)
595 TInt index = FindCacheLineIndex(aPos);
597 return (index == KErrNotFound) ? NULL : (*iCacheLines)[index];
601 TBool CCacheClient::SegmentEmpty(TInt64 aPos)
603 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
605 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound5));
607 TInt startSegment = StartSegment(cacheLine, aPos);
608 TInt fillCount = iManager.FillCount(this, *cacheLine);
611 return startSegment >= fillCount ? (TBool)ETrue : (TBool)EFalse;
615 TBool CCacheClient::SegmentDirty(TInt64 aPos)
617 const CCacheManager::TCacheLine* cacheLine = FindCacheLine(aPos);
619 __ASSERT_ALWAYS(cacheLine != NULL, Fault(ECacheClientSegmentNotFound6));
621 TInt startSegment = StartSegment(cacheLine, aPos);
622 TInt dirtyCount = iManager.DirtyCount(this, *cacheLine);
624 return startSegment >= dirtyCount ? (TBool)ETrue : (TBool)EFalse;
627 // return whether there are too many locked pages globally (for all files)
628 // or too many for this file
629 TBool CCacheClient::TooManyLockedSegments()
631 if (iManager.TooManyLockedSegments())
633 if (LockedBytes() > iMaxBytesCached)
639 TInt CCacheClient::CachedBytes()
641 TInt cacheLineCount = iCacheLines->Count();
643 TInt totalBytesCached = 0;
644 for (TInt n=0; n < cacheLineCount; n++)
645 totalBytesCached+= ((*iCacheLines)[n]->iFilledSegments << iManager.SegmentSizeLog2());
646 return totalBytesCached;
649 TInt CCacheClient::LockedBytes()
651 TInt cacheLineCount = iCacheLines->Count();
652 TInt segmentSizeLog2 = iManager.SegmentSizeLog2();
654 TInt totalBytesLocked = 0;
655 for (TInt n=0; n < cacheLineCount; n++)
657 CCacheManager::TCacheLine& cacheLine = *(*iCacheLines)[n];
658 if (cacheLine.iLockCount > 0)
659 totalBytesLocked+= cacheLine.iAllocatedSegments << segmentSizeLog2;
661 return totalBytesLocked;
664 void CCacheClient::RemoveLru(const CCacheManager::TCacheLine* aCacheLineToExclude)
666 if (iMaxBytesCached == 0) // LRU queue ?
669 // If we've exceeded max, use LRU queue to remove stuff
671 TInt cacheLineCount = iCacheLines->Count();
672 TInt segmentSizeLog2 = iManager.SegmentSizeLog2();
674 // calculate the total bytes cached in all cachelines we own
675 // NB it's difficult to keep a track of this in this class because cachelines can be stolen (!)
676 TInt totalBytesCached = CachedBytes();
677 for (TInt lastIndex = cacheLineCount - 1;
678 lastIndex >= 0 && totalBytesCached > iMaxBytesCached;
681 const CCacheManager::TCacheLine* cacheLine = (*iCacheLines)[lastIndex];
683 // __CACHE_PRINT3(_L("Test cacheline index %d pos %ld len %d"), lastIndex, cacheLine.iPos, cacheLine.iLen);
685 if (cacheLine != aCacheLineToExclude)
687 // if removing a cacheline will bring the total to UNDER the "maximum"
688 // then don't remove it and abort - to do otherwise could remove
689 // data that has just been read-ahead ....
690 TInt lenCacheLine = cacheLine->iFilledSegments << segmentSizeLog2;
691 if (totalBytesCached - lenCacheLine <= iMaxBytesCached)
693 __CACHE_PRINT(_L("CACHECLIENT: cacheline too big to remove, aborting.."));
697 __CACHE_PRINT3(_L("CACHECLIENT: Removing LRU index %d pos %ld len %d"), lastIndex, cacheLine->iPos, CacheLineLen(cacheLine));
698 TInt bytesFreed = cacheLine->iFilledSegments << iManager.SegmentSizeLog2();
699 if (FreeCacheLine(cacheLine))
701 totalBytesCached-= bytesFreed;
702 __ASSERT_ALWAYS(totalBytesCached >= 0, Fault(ECacheClientTotalByteCountInvalid));
710 TBool CCacheClient::FreeCacheLine(const CCacheManager::TCacheLine* aCacheLine)
712 __CACHE_PRINT1(_L("CACHECLIENT: FreeCacheLine(%d) )"), I64LOW(aCacheLine->iPos));
715 TBool success = iManager.FreeCacheLine(this, *aCacheLine);
718 RemoveCacheLine(aCacheLine);
723 void CCacheClient::RemoveCacheLine(const CCacheManager::TCacheLine* aCacheLine)
725 __CACHE_PRINT1(_L("CACHECLIENT: RemoveCacheLine(%d) )"), I64LOW(aCacheLine->iPos));
727 TInt index = iCacheLines->Find(aCacheLine);
729 __ASSERT_ALWAYS(index != KErrNotFound, Fault(ECacheClientSegmentNotFound7));
731 iCacheLines->Remove(index);
734 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
735 void CCacheClient::DumpCache()
737 RDebug::Print(_L("**** CACHECLIENT: CacheLines ****\n"));
738 TInt cacheLineCount = iCacheLines->Count();
740 for (TInt index = 0; index< cacheLineCount; index++)
742 CCacheManager::TCacheLine& cacheLine = *(*iCacheLines)[index];
743 iManager.DumpCacheLine(cacheLine);