author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 17 Sep 2010 08:37:04 +0300 | |
changeset 266 | 0008ccd16016 |
parent 201 | 43365a9b78a3 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfile\sf_cache_client.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalTechnology |
|
21 |
@released |
|
22 |
*/ |
|
23 |
||
24 |
#if !defined(__SF_CACHE_CLIENT_H__) |
|
25 |
#define __SF_CACHE_CLIENT_H__ |
|
26 |
||
27 |
#include "sf_cache_man.h" |
|
28 |
||
29 |
// fwd refs |
|
30 |
class CCacheManager; |
|
31 |
||
32 |
NONSHARABLE_CLASS(CCacheClient) : public CBase |
|
33 |
{ |
|
34 |
public: |
|
35 |
~CCacheClient(); |
|
36 |
void Purge(TBool aPurgeDirty = EFalse); |
|
37 |
||
38 |
TUint8* AllocateAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TBool aMakeDirty, TBool aExtendExisting); |
|
39 |
||
40 |
TUint8* FindAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TInt& aFilledSegmentCount, TInt& aLockError, TBool aMakeDirty); |
|
41 |
TUint8* FindSegment(TInt64 aPos); |
|
42 |
||
43 |
||
44 |
void UnlockSegments(TInt64 aPos); |
|
45 |
||
46 |
||
47 |
void MarkSegmentsAsFilled(TInt64 aPos, TInt aSegmentCount); |
|
48 |
void MarkSegmentsAsDirty(TInt64 aPos, TInt aSegmentCount); |
|
49 |
||
50 |
TInt FindFirstDirtySegment(TInt64& aPos, TUint8*& aAddr); |
|
51 |
||
52 |
void MarkSegmentsAsClean(TInt64 aPos); |
|
53 |
||
54 |
||
55 |
void SetMaxSegments(TInt aMaxSegments); |
|
56 |
||
57 |
TBool SegmentEmpty(TInt64 aPos); |
|
58 |
TBool SegmentDirty(TInt64 aPos); |
|
59 |
TBool TooManyLockedSegments(); |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
TBool LockedSegmentsHalfUsed(); |
0 | 61 |
|
62 |
inline TInt CacheOffset(TInt64 aLinAddr) const \ |
|
63 |
{return(I64LOW(aLinAddr)& ((1 << iManager.SegmentSizeLog2())-1));} |
|
64 |
||
65 |
TInt SegmentSize(); |
|
66 |
TInt SegmentSizeLog2(); |
|
67 |
TInt64 SegmentSizeMask(); |
|
68 |
TInt CacheLineSize(); |
|
69 |
TInt CacheLineSizeInSegments(); |
|
70 |
||
71 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
72 |
void DumpCache(); |
|
73 |
#endif |
|
74 |
||
75 |
private: |
|
76 |
// class can only be instantiated from friend class CCacheManager |
|
77 |
static CCacheClient* NewL(CCacheManager& aManager); |
|
78 |
void ConstructL(); |
|
79 |
CCacheClient(CCacheManager& aManager); |
|
80 |
||
81 |
||
82 |
TInt LockSegments(TInt64 aPos, TInt aSegmentCount, TBool aMakeDirty); |
|
83 |
||
84 |
const CCacheManager::TCacheLine* FindCacheLine(TInt64 aPos); |
|
85 |
TInt FindCacheLineIndex(TInt64 aPos); |
|
86 |
||
87 |
TBool FreeCacheLine(const CCacheManager::TCacheLine* aCacheLine); |
|
88 |
||
89 |
void RemoveCacheLine(const CCacheManager::TCacheLine* aCacheLine); |
|
90 |
void RemoveEmptySegments(const CCacheManager::TCacheLine* aCacheLine); |
|
91 |
||
92 |
void RemoveLru(const CCacheManager::TCacheLine* aCacheLineToExclude); |
|
93 |
||
94 |
inline TInt StartSegment(const CCacheManager::TCacheLine* aCacheLine, TInt64 aPos); |
|
95 |
inline TInt CacheLineLen(const CCacheManager::TCacheLine* aCacheLine); |
|
96 |
||
97 |
TInt CachedBytes(); |
|
98 |
TInt LockedBytes(); |
|
99 |
private: |
|
100 |
CCacheManager& iManager; |
|
101 |
||
102 |
// segment array for segments that contain valid data |
|
103 |
RPointerArray<CCacheManager::TCacheLine>* iCacheLines; |
|
104 |
TInt iMaxBytesCached; |
|
105 |
||
106 |
TInt iLastCacheLineIndex; |
|
107 |
||
108 |
friend class CCacheManager; |
|
109 |
}; |
|
110 |
||
111 |
||
112 |
||
113 |
#endif |