videoconnutility/connutility/inc/vcxconnutilwaitsch.h
branchRCL_3
changeset 47 826cea16efd9
parent 45 798ee5f1972c
child 48 13a33d82ad98
equal deleted inserted replaced
45:798ee5f1972c 47:826cea16efd9
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:    CCVcxConnUtilWaitSch class declaration file*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CVCXCONNUTILWAITSCH_H
       
    21 #define __CVCXCONNUTILWAITSCH_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <e32hashtab.h>
       
    27 
       
    28 
       
    29 class CVcxConnUtilWait;
       
    30 class CActiveSchedulerWait;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  * CVcxConnUtilWaitSch is used to manage CActiveSchedulerWait objects
       
    36  * within videoconnutility.
       
    37  * Basically, when client calls wait, a new CActiveSchedulerWait is created 
       
    38  * and being put to list. Different types for waits are managed by different
       
    39  * wait -wrapper object, which type is defined as a private class for this class.
       
    40  * 
       
    41  * Currently videoconnutility puts active objects to wait in following situations:
       
    42  * 
       
    43  * (1) When there is connection creation ongoing and other active objects try to 
       
    44  * create connection: only the one active object that is creating connection is runnig, 
       
    45  * other a-objects waits as long as connection is ready
       
    46  * 
       
    47  * (2) Master waiting for roaming status from slave instances: Master's roaming active object is 
       
    48  * waiting for roaming response status change.
       
    49  * 
       
    50  * (3) Connection creation during roaming: All active objects requesting connection during roaming
       
    51  * are put to wait for the roaming to finish, so that correct iap id can be returned.
       
    52  * 
       
    53  * (4) Disconnecting during roaming. Master's disconnecting a-object(s) is put to wait for
       
    54  * roaming to finish
       
    55  * 
       
    56  * Waiting is released by the client by calling EndWait. CVcxConnUtilWaitSch basicallly 
       
    57  * stops wait for every wait object, put those whose type is not the one provided 
       
    58  * by the parameter of EndWait are being put back to wait. This solution is needed, to 
       
    59  * prevent deadlocks: we might have different kind of waits at the same time, but not all
       
    60  * are to be released at the same time, but because of the nature of the ActiveScheduler,
       
    61  * all wait objects are needed to release once, before anyone can proceed.
       
    62  * 
       
    63  * 
       
    64  */
       
    65 NONSHARABLE_CLASS( CVcxConnUtilWaitSch ) : public CBase
       
    66     {
       
    67     public: // Constructors and destructor
       
    68 
       
    69         /**
       
    70          * Destructor.
       
    71          */
       
    72         ~CVcxConnUtilWaitSch();
       
    73     
       
    74         /**
       
    75          * Two-phased constructor.
       
    76          */
       
    77         static CVcxConnUtilWaitSch* NewL();
       
    78     
       
    79         /**
       
    80          * Two-phased constructor.
       
    81          */
       
    82         static CVcxConnUtilWaitSch* NewLC();
       
    83 
       
    84     private:
       
    85 
       
    86         /**
       
    87          * Constructor for performing 1st stage construction
       
    88          */
       
    89         CVcxConnUtilWaitSch();
       
    90     
       
    91         /**
       
    92          * EPOC default constructor for performing 2nd stage construction
       
    93          */
       
    94         void ConstructL();
       
    95     
       
    96     public:
       
    97   
       
    98         /**
       
    99          * Method creates a new CVcxConnUtilWait object in case
       
   100          * one with provided type does not already exist, then
       
   101          * creates a CActiveSchedulerWait object for the current
       
   102          * active object and puts it to wait by calling 
       
   103          * CActiveSchedulerWait::Start. After call returns (wait has 
       
   104          * released) checks if CVcxConnUtilWait's iCanStop is ETrue.
       
   105          * In case it is not, the object is being put back to wait. 
       
   106          * 
       
   107          * After wait object is really released, it is being deallocated. 
       
   108          * 
       
   109          * Method leaves with systemwide error code, in case object 
       
   110          * creation or saving to array fails.
       
   111          * 
       
   112          * @param aWaitId wait type id for this wait
       
   113          */
       
   114         void WaitL( TUint32 aWaitId );
       
   115         
       
   116         
       
   117         /**
       
   118          * Method loops all CVcxConnUtilWait objects and sets their
       
   119          * iCanStop to ETrue, in case aWaitId is same as CVcxConnUtilWait's
       
   120          * iType. 
       
   121          * All CActiveSchedulerWait's for each CVcxConnUtilWait is being 
       
   122          * released by calling CActiveSchedulerWait::AsyncStop.
       
   123          * 
       
   124          * @param aWaitId wait type id for this wait
       
   125          */
       
   126         void EndWait( TUint32 aWaitId );
       
   127         
       
   128     
       
   129     private:
       
   130                          
       
   131         /**
       
   132          * Internal helper method for getting corresponding 
       
   133          * CVcxConnUtilWait object based in the aID. 
       
   134          * 
       
   135          * In case aID -type object is not found from the 
       
   136          * iWaits -array, it is being created and appended to array.
       
   137          * 
       
   138          * @param aID wait type id for this wait
       
   139          */
       
   140         CVcxConnUtilWait* GetWaitL( TUint32 aID );
       
   141         
       
   142         /**
       
   143          * Internal helper method for PrepareWaitObjectL for 
       
   144          * getting next not started Active scheduler wait 
       
   145          * object for given CVcxConnUtilWait.
       
   146          * 
       
   147          * If there is no existing not started object or given
       
   148          * CVcxConnUtilWait is NULL a new  CActiveSchedulerWait
       
   149          * object is created and appended to the aWait object's
       
   150          * waitarray.
       
   151          * 
       
   152          * 
       
   153          * @param aWait wait wait object from where to search
       
   154          */
       
   155         CActiveSchedulerWait* GetActiveSWaitL( CVcxConnUtilWait* aWait );
       
   156         
       
   157     private:       
       
   158         /**
       
   159          * Array containing all CVcxConnUtilWait objects maintained
       
   160          * by this object  
       
   161          */
       
   162         RPointerArray< CVcxConnUtilWait > iWaits;
       
   163 
       
   164     };
       
   165 
       
   166 #endif // __CVCXCONNUTILWAITSCH_H