|
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 * RMBufPoolChain declaration |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef MBUF_POOL_CHAIN_H |
|
26 #define MBUF_POOL_CHAIN_H |
|
27 |
|
28 #include "commsbufpool.h" |
|
29 |
|
30 // forward decleration(s) to avoid circular dependency by including this file |
|
31 // - this is a symptom of multiple class declerations within the same header file |
|
32 // eg. es_mbman.h required for CMBufPool, but also contains CMBufManager which inturn requires RMBufPoolChain defined in this file! |
|
33 class RMBufPoolChain; |
|
34 class CMBufPool; |
|
35 class CMBufPoolManager; |
|
36 |
|
37 #include <es_mbuf.h> |
|
38 #include <elements/rworkerlock.h> // RWorkerThread decleration |
|
39 class CCommsBufPool; |
|
40 // this class is internal to MBM, but alas this can't be enforced by C++ (except by not exporting its header file) |
|
41 NONSHARABLE_CLASS(CMBufPoolChain) : public CCommsBufPool |
|
42 { |
|
43 friend class CMBufPoolManager; // to allow access to private members |
|
44 |
|
45 |
|
46 public: |
|
47 static CMBufPoolChain* NewL(TInt aMBufSize, TInt aInitialAllocation, TInt aMinGrowth, TInt aHighGrowthThresholdPercentage, TInt aPoolCeiling, CMBufPoolManager& aMBufPoolManager); |
|
48 ~CMBufPoolChain(); |
|
49 |
|
50 TInt GrowthSize(TInt aSize); |
|
51 void ExtendFreeList(CMBufPool* aPool); // assumed that the caller has already acquired the lock, refer comments within the definition |
|
52 |
|
53 TInt Alloc(RMBufQ& aList, TInt aSize, TBool aIsAllocPool); |
|
54 static TInt Compare(const TInt* aMBufSize, const CMBufPoolChain& aRHSPoolChain); |
|
55 static TInt Compare(const CMBufPoolChain& aLHSPoolChain, const CMBufPoolChain& aRHSPoolChain); |
|
56 |
|
57 CMBufPoolManager& MBufPoolManager(); |
|
58 |
|
59 TBool CanExtend() const; |
|
60 TInt ExtendSize() const; |
|
61 TBool HonourPoolCeiling() const; |
|
62 private: |
|
63 CMBufPoolChain(TInt aMBufSize, TInt aInitialAllocation, TInt aMinGrowth, TInt aHighGrowthThresholdPercentage, TInt aPoolCeiling, CMBufPoolManager& aMBufPoolManager); |
|
64 CMBufPoolChain(TInt aMBufSize, CMBufPoolManager& aMBufPoolManager); // to be used only in searching for existing poolchain |
|
65 |
|
66 void ConstructL(); |
|
67 private: |
|
68 |
|
69 RWorkerLock iLockFreeList; // lock for free list |
|
70 TInt iLenFree; // number of bytes free within the pool chain |
|
71 TInt iLenTotal; // number of bytes allocated (free + used) within the pool chain |
|
72 RMBufQ iFreeMBufs; // free list of mbufs ready to be consumed, use of plural naming implies the queue (hence the name isn't appended) |
|
73 TDblQue<CMBufPool> iPools; |
|
74 |
|
75 const TInt iInitialAllocation; // initial allocation size in num of MBufs (not bytes) |
|
76 TInt iMinGrowth; // minimum (automatic) incremental allocation in num of MBufs (not bytes) - actual allocate may be larger (refer ) |
|
77 TInt iGrowthThreshold; // if the num of free mbufs is <= this value, then a a new pool is automatically allocated |
|
78 |
|
79 TBool iSignalled; // background growth in progress |
|
80 TInt iNumMBufsToAdd; // background growth |
|
81 TBool iNoMoreSpace; // last background growth failed |
|
82 TInt iLastGrowth; // last attempted growth |
|
83 TInt iMaxGrowthAttempt; // largest growth attempt |
|
84 |
|
85 TInt iDbgPoolLimit; // limit size of pool chain |
|
86 TInt iPoolCeiling; // Pool size limit in bytes |
|
87 CMBufPoolManager& iMBufPoolManager; |
|
88 }; |
|
89 |
|
90 #endif // MBUF_POOL_CHAIN_H |