commsfwutils/commsbufs/mbufmgrimpl/inc/MBufPoolManager.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 /**
       
     2 * Copyright (c) 2007-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 * CMBufPoolManager decleration
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 /**
       
    21 @file
       
    22 @internalTechnology
       
    23 */
       
    24 
       
    25 #ifndef MBUF_POOL_MANAGER_H
       
    26 #define MBUF_POOL_MANAGER_H
       
    27 
       
    28 #include <e32def.h>				// for std types
       
    29 #include "MBufSizeAllocator.h"	// for MMBufSizeAllocator
       
    30 #include "MBufManager.h"		// for CMBufManager
       
    31 
       
    32 class CMBufPoolChain;
       
    33 class CMBufPool;
       
    34 NONSHARABLE_CLASS(CMBufPoolManager) : public CActive, public MMBufSizeAllocator
       
    35 	{
       
    36 
       
    37 public:
       
    38 	static CMBufPoolManager* NewL(TInt aMaxAllocSize, CMBufManager& aMBufManager);
       
    39 	virtual ~CMBufPoolManager();
       
    40 
       
    41 	CMBufMemoryAllocator& Memory();
       
    42 	CMBufManager&	Manager();
       
    43 	void WaitForNewPoolRequest();
       
    44 	TInt BackgroundAllocateNewPool(CMBufPoolChain& aPoolChain, TInt aNumMBufs);
       
    45 
       
    46 	void AddL(TInt aMBufSize, TInt aInitialAllocation, TInt aMinGrowth, TInt aGrowthThreshold, TInt aPoolCeiling);
       
    47 	TInt Commit();
       
    48 
       
    49 	RMBuf* Alloc(TInt aSize, TInt aMinMBufSize, TInt aMaxMBufSize, TBool aIsAllocPool);	
       
    50 	TInt AllocPool(CMBufPoolChain& aPoolChain, TInt aSize, TBool aIsSynchronous);
       
    51 	void Free(RMBuf* aMBuf, TBool aIsPreAlloc);
       
    52 	TUint LargestMBufSize() {return iLargestMBufSize;}
       
    53 	TInt NextMBufSize(TInt aSize);
       
    54 	TInt BytesAvailable();
       
    55 	TInt BytesAvailable(TInt aSize);
       
    56 	TInt BytesAllocated();
       
    57 	
       
    58 	TInt __DbgCheckBuffer(RMBuf* aBuf);
       
    59 	TUint __DbgGetBufSpace();
       
    60 	TUint __DbgGetBufSpace(TUint aMBufSize);
       
    61 	TUint __DbgGetBufTotal();
       
    62 	TUint __DbgGetBufTotal(TUint aMBufSize);
       
    63 	RMBuf* __DbgMBufChain();
       
    64 	RMBuf* __DbgMBufChain(TUint aMBufSize);
       
    65 	void __DbgSetPoolLimit(TInt aCount);
       
    66 	void __DbgSetPoolLimit(TInt aCount, TUint aMBufSize);
       
    67 	
       
    68 private:
       
    69 	CMBufPoolManager(TInt aMaxAllocSize, CMBufManager& aMBufManager);
       
    70 	void ConstructL(TInt aMaxAllocSize);
       
    71 
       
    72 	virtual void DoCancel();
       
    73 	virtual void RunL();
       
    74 	
       
    75 	void LinearSearchAlloc(RMBufQ& aList, TInt aSize, TInt aMinMBufSize, TInt aMaxMBufSize, TBool aIsAllocPool);
       
    76 
       
    77 	virtual void CreatePool(CMBufPool* &aNewpool, CMBufPoolChain& aMBufPoolChain);
       
    78 
       
    79     RPointerArray<CMBufPoolChain> iPoolChains;
       
    80 
       
    81 	RWorkerLock iPoolChainLock;
       
    82 	RThread iMBufMgrOwnerThread;
       
    83 	TBool iSignalled;
       
    84 	TInt iNextMBufSize;				// Next requested growth request
       
    85 
       
    86 	TInt iLargestMBufSize;
       
    87 
       
    88 	TInt iMaxAllocSize;
       
    89 	TInt iAllocSize;
       
    90 
       
    91 	TBool iCommitted;
       
    92 
       
    93 	CMBufManager& iMBufManager;		// for callback after freeing
       
    94 	CMBufMemoryAllocator* iMemoryAllocator;
       
    95 	
       
    96 	};
       
    97 
       
    98 #endif  // MBUF_POOL_MANAGER_H