servicediscoveryandcontrol/pnp/test/upnp/chunkmgr/inc/cchunkmanager.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 // @file
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __CCHUNKMANAGER_H_
       
    20 #define __CCHUNKMANAGER_H_
       
    21 
       
    22 #include <e32def.h>
       
    23 
       
    24 //Forward declaration
       
    25 class CChunkAllocator;
       
    26 class RChunkPool;
       
    27 class RMemCellList;
       
    28 class RMemCell;
       
    29 
       
    30 class CChunkManager : public CBase
       
    31 	{
       
    32 public:
       
    33 	IMPORT_C static CChunkManager* NewL ( TInt aHeapSize );
       
    34 	IMPORT_C ~CChunkManager ();
       
    35 	
       
    36 	IMPORT_C void AddPoolL ( TInt aBlockSize, TInt aNumBlocks, TInt aThresholdValue, TInt aMinGrowth );
       
    37 	
       
    38 	CChunkAllocator& Allocator ();
       
    39 	TInt AllocChunk ( RChunkPool& aChunkPool, TInt aNumBlocks );
       
    40 	RMemCell* Alloc ( TInt aSize );
       
    41 	void Free ( RMemCell* aPtr );
       
    42 	
       
    43 	// returns free space that can be used for CMemChunk after excluding sizeof CMemChunk
       
    44 	TInt BytesAvailable ();
       
    45 	
       
    46 private:
       
    47 	CChunkManager ( TInt aHeapSize );
       
    48 	void ConstructL ();	
       
    49 	void SearchAndAlloc ( RMemCellList& aList, TInt aSize );	
       
    50 	
       
    51 private:
       
    52 	CChunkAllocator* 	iChunkAllocator;
       
    53 	RArray<RChunkPool> 	iChunkPools;
       
    54 	RFastLock 			iLock;
       
    55 	TInt				iHeapSize;
       
    56 	TInt				iUsedSpace;
       
    57 	};
       
    58 
       
    59 #endif /*__CCHUNKMANAGER_H_*/