commsfwutils/commsbufs/inc/commsbufpond.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 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: Collection of shared buffers and allocator support
       
    14 // to speed up the allocation 
       
    15 //
       
    16 
       
    17 #ifndef __COMMSBUFPOND_H__ 
       
    18 #define __COMMSBUFPOND_H__
       
    19 
       
    20 /**
       
    21 Standard aligned buffer for transfer of pond info between comms and kernel commsbuf drivers
       
    22 */
       
    23 typedef TBuf8<144> TPondTransferBuf;
       
    24 
       
    25 
       
    26 #ifndef __KERNEL_MODE__
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <e32shbuf.h>
       
    30 
       
    31 class TCommsBufPoolCreateInfo;
       
    32 class RCommsBuf;
       
    33 class MCommsBufPondIntf;
       
    34 class RCommsBufAsyncRequest;
       
    35 class RCommsBufPond;
       
    36 
       
    37 /**
       
    38 TCommsBufAllocator provides a handle to the allocator to speed up the allocation without 
       
    39 internally accessing the Thread Local Storage. 
       
    40 
       
    41 @publishedPartner
       
    42 @prototype
       
    43 */
       
    44 class TCommsBufAllocator
       
    45 	{
       
    46 	friend class RCommsBuf;
       
    47 	friend class RCommsBufChain;
       
    48 	friend class RCommsBufPond;
       
    49 	friend class RMBufAllocator;
       
    50 	friend class RMBufChain;
       
    51 	friend class RMBuf;
       
    52 	friend class CCommsBufAsyncRequest;
       
    53 	
       
    54 	private:
       
    55 	inline TCommsBufAllocator(RCommsBufPond aPond);
       
    56 	MCommsBufPondIntf&	iPond;
       
    57 	};
       
    58 
       
    59 class CSystemSharedBufPond;
       
    60 /**
       
    61 The RCommsBufPond represents a collection of RShPools. Each pool in the pond has a different
       
    62 size of buffer. The pond is responsible for creating, allocating and freeing these pools. 
       
    63 
       
    64 @publishedPartner
       
    65 @prototype
       
    66 */
       
    67 class RCommsBufPond
       
    68 	{
       
    69 	friend class RCommsBufPondInternalOp;
       
    70 	friend class TCommsBufAllocator;
       
    71 	friend class RCommsBuf;
       
    72 	friend class TCommsBufPondTLSOp;
       
    73 	friend class TCommsBufPondDbg;
       
    74 
       
    75 	public:
       
    76 	IMPORT_C RCommsBufPond();
       
    77 
       
    78 	IMPORT_C RCommsBuf* Alloc(TInt aSize, TInt aMinBufSize, TInt aMaxBufSize);
       
    79 	IMPORT_C RCommsBuf* FromHandle(TInt aHandle);
       
    80 	IMPORT_C TInt Store(TPondTransferBuf& aStore) const;
       
    81 
       
    82 	IMPORT_C TInt BytesAvailable() const;
       
    83 	IMPORT_C TInt BytesAvailable(TInt aSize) const;
       
    84 	IMPORT_C TInt NextBufSize(TInt aSize) const;
       
    85 	IMPORT_C TInt LargestBufSize() const;
       
    86 	
       
    87 	IMPORT_C TCommsBufAllocator Allocator();
       
    88 	
       
    89 	inline TBool IsNull() const;
       
    90 	private:
       
    91     IMPORT_C void StartRequest(RCommsBufAsyncRequest& aRequest);
       
    92     IMPORT_C void CancelRequest(RCommsBufAsyncRequest& aRequest);
       
    93 	
       
    94     CSystemSharedBufPond& Pond() const;
       
    95 	inline	RCommsBufPond(MCommsBufPondIntf* aPondImpl);
       
    96 	protected:
       
    97 	MCommsBufPondIntf* iPondImpl;	// The pond implementation. This can be the legacy MBufMgr or the new system wide
       
    98 									// shared buffer implementation
       
    99 	};
       
   100 
       
   101 #endif // __KERNEL_MODE__
       
   102 
       
   103 #endif // __COMMSBUFPOND_H__
       
   104 #include <comms-infras/commsbufpond.inl>