profilesservices/ProfileEngine/tsrc/public/basic/WrapperMdlTest/src/MT_CSchedulerUtility.cpp
changeset 0 8c5d936e5675
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  This singleton class takes care of creation of different other
       
    15 *                classes needed in PECProfiles.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "MT_CSchedulerUtility.h"
       
    23 #include    <e32svr.h>
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // MT_CSchedulerUtility::MT_CSchedulerUtility
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 MT_CSchedulerUtility::MT_CSchedulerUtility()
       
    34     {
       
    35     RDebug::Print( _L( "Digia:MT_CSchedulerUtility::MT_CSchedulerUtility()" ) );
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // MT_CSchedulerUtility::ConstructL
       
    40 // Symbian 2nd phase constructor can leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void MT_CSchedulerUtility::ConstructL()
       
    44     {
       
    45     iWait = new ( ELeave ) CActiveSchedulerWait;
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // MT_CSchedulerUtility::NewL
       
    50 // Two-phased constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 MT_CSchedulerUtility* MT_CSchedulerUtility::NewL()
       
    54     {
       
    55     MT_CSchedulerUtility* self = new( ELeave ) MT_CSchedulerUtility;
       
    56     
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop();
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64     
       
    65 // Destructor
       
    66 MT_CSchedulerUtility::~MT_CSchedulerUtility()
       
    67     {
       
    68     Stop();
       
    69     delete iWait;
       
    70     Dll::SetTls( NULL );
       
    71     RDebug::Print( _L( "Digia:MT_CSchedulerUtility::~MT_CSchedulerUtility()" ) );
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // MT_CSchedulerUtility::InstanceL
       
    77 // (other items were commented in a header).
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 MT_CSchedulerUtility* MT_CSchedulerUtility::InstanceL()
       
    81     {
       
    82     TAny* instance = Dll::Tls();
       
    83     if( instance == NULL )
       
    84         {
       
    85         instance = MT_CSchedulerUtility::NewL();
       
    86         TInt err( Dll::SetTls( instance ) );
       
    87         if( err )
       
    88             {
       
    89             delete static_cast<MT_CSchedulerUtility*>( instance );
       
    90             User::Leave( err );
       
    91             }
       
    92         }
       
    93     return static_cast<MT_CSchedulerUtility*>( instance );
       
    94     }
       
    95 
       
    96 void MT_CSchedulerUtility::Release()
       
    97     {
       
    98     TAny* instance = Dll::Tls();
       
    99     if( instance != NULL )
       
   100         {
       
   101         delete ( static_cast<MT_CSchedulerUtility*>( instance ) );
       
   102         }
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // MT_CSchedulerUtility::Start
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void MT_CSchedulerUtility::Start()
       
   111     {
       
   112     if( !iWait->IsStarted() )
       
   113         {
       
   114         iWait->Start();
       
   115         }
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // MT_CSchedulerUtility::Stop
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void MT_CSchedulerUtility::Stop()
       
   124     {
       
   125     if( iWait->IsStarted() )
       
   126         {
       
   127         iWait->AsyncStop();
       
   128         }
       
   129     }
       
   130 
       
   131 //  End of File  
       
   132