|
1 // Copyright (c) 2007-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 "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 // |
|
15 |
|
16 #ifndef __WSMEMMGR_H__ |
|
17 #define __WSMEMMGR_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 class CWsMemoryManager: public CBase, private RAllocator |
|
22 { |
|
23 public: |
|
24 static CWsMemoryManager * NewLC(); |
|
25 ~CWsMemoryManager(); |
|
26 |
|
27 void EnableReserve(); |
|
28 void DisableReserve(); |
|
29 |
|
30 public: |
|
31 static CWsMemoryManager * Static(); |
|
32 TInt Count() const; |
|
33 |
|
34 void SetFailNextRetry(); |
|
35 private: |
|
36 CWsMemoryManager(); |
|
37 void ConstructL(); |
|
38 // implementing RAllocator |
|
39 TAny* Alloc(TInt aSize); |
|
40 void Free(TAny* aPtr); |
|
41 TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode); |
|
42 TInt AllocLen(const TAny* aCell) const; |
|
43 TInt Compress(); |
|
44 void Reset(); |
|
45 TInt AllocSize(TInt& aTotalAllocSize) const; |
|
46 TInt Available(TInt& aBiggestBlock) const; |
|
47 TInt DebugFunction(TInt aFunc, TAny* a1, TAny* a2); |
|
48 |
|
49 |
|
50 private: |
|
51 static CWsMemoryManager * iStatic; |
|
52 |
|
53 private: |
|
54 RAllocator* iImpl; |
|
55 TBool iReleasing; |
|
56 TBool iReserveEnabled; |
|
57 TInt iReserveSize; |
|
58 TAny* iReserve; |
|
59 TBool iFailNextRetry; |
|
60 TTime iCurrentBurstStart; |
|
61 TInt iCurrentBurstReleaseCount; |
|
62 }; |
|
63 |
|
64 #endif //__WSMEMMGR_H__ |
|
65 |