|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef LOADGEN_MEMORYEAT_H |
|
20 #define LOADGEN_MEMORYEAT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include <e32hal.h> |
|
27 |
|
28 #include "loadgen_loadbase.h" |
|
29 #include "loadgen_loadattributes.h" |
|
30 |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 |
|
34 |
|
35 |
|
36 // CLASS DECLARATIONS |
|
37 |
|
38 class CMemoryEat : public CLoadBase |
|
39 { |
|
40 public: |
|
41 static CMemoryEat* NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); |
|
42 virtual ~CMemoryEat(); |
|
43 |
|
44 private: // Constructors |
|
45 CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); |
|
46 void ConstructL(); |
|
47 |
|
48 public: // New methods |
|
49 virtual void Resume(); |
|
50 virtual void Suspend(); |
|
51 virtual void SetPriority(); |
|
52 virtual void Close(); |
|
53 virtual TPtrC Description(); |
|
54 inline TMemoryEatAttributes& Attributes() { return iAttributes; } |
|
55 inline void SetAttributes(TMemoryEatAttributes aAttributes) { iAttributes = aAttributes; } |
|
56 |
|
57 public: // New static methods |
|
58 static TInt ThreadFunction(TAny* aThreadArg); |
|
59 private: |
|
60 static void GenerateLoad(TMemoryEatAttributes& aAttributes); |
|
61 |
|
62 private: // Data |
|
63 TMemoryEatAttributes iAttributes; |
|
64 RThread iThread; |
|
65 }; |
|
66 |
|
67 |
|
68 class CMemoryEatManager : public CActive |
|
69 { |
|
70 public: |
|
71 static CMemoryEatManager* NewL(TMemoryEatAttributes& aAttributes); |
|
72 ~CMemoryEatManager(); |
|
73 |
|
74 private: |
|
75 CMemoryEatManager(TMemoryEatAttributes& aAttributes); |
|
76 void ConstructL(); |
|
77 |
|
78 private: |
|
79 void RunL(); |
|
80 void DoCancel(); |
|
81 |
|
82 private: |
|
83 static TInt PeriodicTimerCallBack(TAny* aAny); |
|
84 void InitMemoryEatL(); |
|
85 void DestroyMemoryEat(); |
|
86 void EatMemoryL(); |
|
87 void DoEatMemoryL( TInt64 aNewSize ); |
|
88 void HandleEatMemoryL( TInt64 aNewSize ); |
|
89 void AllocMemoryL( TInt64 aNewSize ); |
|
90 void FreeMemoryL( TInt64 aNewSize ); |
|
91 TInt64 ReadFreeMemory(); |
|
92 |
|
93 |
|
94 public: |
|
95 inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } |
|
96 |
|
97 private: |
|
98 TMemoryEatAttributes& iAttributes; |
|
99 CPeriodic* iPeriodicTimer; |
|
100 RChunk iEatChunk; |
|
101 RFile iEatFile; |
|
102 RFs iFs; |
|
103 TBool iWavyEatMoreMemory; |
|
104 TInt iFilesCounter; |
|
105 }; |
|
106 |
|
107 |
|
108 #endif |