commsfwutils/commsbufs/mbufmgr/src/mb_asy.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 // Buffer Manager for Protocols(ASync alloc)
       
    15 
       
    16 /**
       
    17 @file
       
    18 
       
    19 Buffer Manager for Protocols(ASync alloc)
       
    20 
       
    21 @internalComponent
       
    22 */
       
    23 
       
    24 #include <es_mbuf.h>
       
    25 #include <cflog.h>
       
    26 #include <comms-infras/commsbufpond.h>
       
    27 #include <comms-infras/commsbufpondop.h>
       
    28 #include "commsbufasyncreqinternal.h"
       
    29 //
       
    30 // ASYNC ALLOCATOR SUPPORT
       
    31 //
       
    32 /**
       
    33 Constructor inisialiser.
       
    34 */
       
    35 EXPORT_C RMBufAsyncRequest::RMBufAsyncRequest()
       
    36 : RCommsBufAsyncRequest()
       
    37 	{
       
    38 	}
       
    39 
       
    40 /**
       
    41 Destructor.
       
    42 */
       
    43 EXPORT_C RMBufAsyncRequest::~RMBufAsyncRequest()
       
    44 	{
       
    45 	RCommsBufAsyncRequest::Close();
       
    46 	}
       
    47 
       
    48 /**
       
    49 Allocates memory for a MBuf Chain
       
    50 - refer RMBufChain::AllocL notes regarding the deliberate decision not to provide an overloaded min/max mbuf size variant
       
    51 @param aChain The chain
       
    52 @param aLenth The length of the chain
       
    53 @param aStatus KErrNone if successful.
       
    54 */
       
    55 EXPORT_C void RMBufAsyncRequest::Alloc(RMBufChain& aChain, TInt aLength, TRequestStatus& aStatus)
       
    56 	{
       
    57 	TInt err = KErrNone;
       
    58 	if(iAsyncReqImpl == NULL)
       
    59 	    {
       
    60 	    TCommsBufAllocator allocator = TCommsBufPondTLSOp::Get().Allocator();
       
    61 	    err = RCommsBufAsyncRequest::Open(allocator);    
       
    62 	    }
       
    63 	 
       
    64 	if(err != KErrNone)
       
    65 	    {
       
    66 	    TRequestStatus* reqStatusPtr = &aStatus;
       
    67 	    User::RequestComplete(reqStatusPtr, err);	    
       
    68 	    }
       
    69 	else
       
    70 	    {
       
    71         RCommsBufAsyncRequest::Alloc(aChain, aLength, aStatus);
       
    72         if(aStatus.Int() == KErrNone)
       
    73             {
       
    74             // Our allocation is success. Close the implementation.
       
    75             RCommsBufAsyncRequest::Close();
       
    76             }	    
       
    77 	    }	
       
    78 	}
       
    79 
       
    80 /**
       
    81 Cancels outstanding request.
       
    82 */
       
    83 EXPORT_C void RMBufAsyncRequest::Cancel()
       
    84 	{
       
    85 	RCommsBufAsyncRequest::Cancel();
       
    86 	}
       
    87 
       
    88 /**
       
    89 Completes the request.
       
    90 @param aCode The completion code (status).
       
    91 */
       
    92 EXPORT_C void RMBufAsyncRequest::Complete(TInt aCode)
       
    93 	{
       
    94 	RCommsBufAsyncRequest::Complete(aCode);
       
    95 	}
       
    96 /**
       
    97  Copy constructor
       
    98  */
       
    99 EXPORT_C RMBufAsyncRequest::RMBufAsyncRequest(const RMBufAsyncRequest& /* aObj */)
       
   100     {
       
   101     // Note: We do not copy anything here. Note that we are deleting the implementation in
       
   102     // the d'tor. So we shouldn't allow to do a copy or assignment of our object.
       
   103     }
       
   104 
       
   105 /**
       
   106 Assignment operator.
       
   107  */
       
   108 EXPORT_C RMBufAsyncRequest& RMBufAsyncRequest::operator=(const RMBufAsyncRequest& /* aRhs */)
       
   109     {
       
   110     // See note on the copy c'tor.
       
   111     return *this;
       
   112     }
       
   113 
       
   114 EXPORT_C TInt* RMBufAsyncRequest::Length()
       
   115     {
       
   116     if(iAsyncReqImpl)
       
   117         {
       
   118         return &iAsyncReqImpl->iSize;
       
   119         }
       
   120     return NULL;
       
   121     }
       
   122 
       
   123 EXPORT_C RMBufQ* RMBufAsyncRequest::MBufQ()
       
   124     {
       
   125     if(iAsyncReqImpl)
       
   126          {
       
   127          return static_cast<RMBufQ*>(&iAsyncReqImpl->iBufQ);
       
   128          }
       
   129      return NULL;        
       
   130     }
       
   131 
       
   132 EXPORT_C RMBufChain* RMBufAsyncRequest::MBufChain()
       
   133     {
       
   134     if(iAsyncReqImpl)
       
   135         {
       
   136         return static_cast<RMBufChain*>(iAsyncReqImpl->iChain);
       
   137         }
       
   138     return NULL;          
       
   139     }
       
   140 
       
   141 EXPORT_C TRequestStatus* RMBufAsyncRequest::RequestStatusPtr()
       
   142     {
       
   143     if(iAsyncReqImpl)
       
   144         {
       
   145         return iAsyncReqImpl->iStatusPtr;
       
   146         }
       
   147     return NULL;            
       
   148     }
       
   149 
       
   150 EXPORT_C RThread* RMBufAsyncRequest::Thread()
       
   151     {
       
   152     if(iAsyncReqImpl)        
       
   153         {
       
   154         return &iAsyncReqImpl->iThread;
       
   155         }
       
   156     return NULL;   
       
   157     }
       
   158 
       
   159 EXPORT_C TDblQueLink* RMBufAsyncRequest::DblQueLink()
       
   160     {
       
   161     if(iAsyncReqImpl)        
       
   162          {
       
   163          return &iAsyncReqImpl->iLink;
       
   164          }
       
   165      return NULL;   
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------