loadgen/inc/loadgen_memoryeat.h
branchRCL_3
changeset 21 b3cee849fa46
parent 20 48060abbbeaf
child 22 fad26422216a
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
     1 /*
       
     2 * Copyright (c) 2009 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 
       
    27 #include "loadgen_loadbase.h"
       
    28 #include "loadgen_loadattributes.h"
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 
       
    34 
       
    35 // CLASS DECLARATIONS
       
    36 
       
    37 class CMemoryEat : public CLoadBase
       
    38     {
       
    39 public:
       
    40     static CMemoryEat* NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber);
       
    41     virtual ~CMemoryEat();
       
    42         
       
    43 private: // Constructors
       
    44     CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber);
       
    45     void ConstructL();  
       
    46 
       
    47 public:  // New methods
       
    48     virtual void Resume();
       
    49     virtual void Suspend();
       
    50     virtual void SetPriority();
       
    51     virtual void Close();
       
    52     virtual TPtrC Description();
       
    53     inline TMemoryEatAttributes& Attributes() { return iAttributes; }
       
    54 
       
    55 public:  // New static methods
       
    56     static TInt ThreadFunction(TAny* aThreadArg);
       
    57 private:
       
    58     static void GenerateLoad(TMemoryEatAttributes& aAttributes);
       
    59 
       
    60 private: // Data
       
    61     TMemoryEatAttributes    iAttributes;    
       
    62     RThread                 iThread;
       
    63     };
       
    64 
       
    65 
       
    66 class CMemoryEatManager : public CActive
       
    67     {
       
    68 public:
       
    69     static CMemoryEatManager* NewL(TMemoryEatAttributes& aAttributes);
       
    70     ~CMemoryEatManager();
       
    71 
       
    72 private:
       
    73     CMemoryEatManager(TMemoryEatAttributes& aAttributes);
       
    74     void ConstructL();
       
    75 
       
    76 private:
       
    77     void RunL();
       
    78     void DoCancel();
       
    79 
       
    80 private:
       
    81     static TInt PeriodicTimerCallBack(TAny* aAny);
       
    82     void InitMemoryEatL();
       
    83     void DestroyMemoryEat();
       
    84     void EatMemoryL();
       
    85     void DoEatMemoryL( TInt64 aNewSize );
       
    86     void HandleEatMemoryL( TInt64 aNewSize );
       
    87     void AllocMemoryL( TInt64 aNewSize );
       
    88     void FreeMemoryL( TInt64 aNewSize );
       
    89     TInt64 ReadFreeMemory();
       
    90     
       
    91 
       
    92 public:
       
    93     inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; }
       
    94 
       
    95 private:
       
    96     TMemoryEatAttributes&   iAttributes;    
       
    97     CPeriodic*              iPeriodicTimer;
       
    98     RChunk                  iEatChunk;
       
    99     RFile                   iEatFile;
       
   100     RFs                     iFs;
       
   101     TBool                   iWavyEatMoreMemory;
       
   102     TInt     iFilesCounter;
       
   103     };
       
   104      
       
   105 
       
   106 #endif