contextframework/cfw/src/cfactivatorengine/CFActivatorTimedSchedulerWait.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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:  CCFActivatorTimedSchedulerWait class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "CFActivatorTimedSchedulerWait.h"
       
    21 #include "cftrace.h"
       
    22 
       
    23 // CONSTANTS
       
    24 
       
    25 _LIT( KPanicCat, "ActTimSche" );
       
    26 
       
    27 enum TPanicReason
       
    28     {
       
    29     EAlreadyStarted
       
    30     };
       
    31     
       
    32 LOCAL_C void Panic( TInt aCode )
       
    33     {
       
    34     User::Panic( KPanicCat, aCode );
       
    35     }
       
    36 
       
    37 // MEMBER FUNCTIONS
       
    38 
       
    39 CCFActivatorTimedSchedulerWait* CCFActivatorTimedSchedulerWait::NewL()
       
    40     {
       
    41     FUNC_LOG;    
       
    42 
       
    43     CCFActivatorTimedSchedulerWait* self =
       
    44         CCFActivatorTimedSchedulerWait::NewLC();
       
    45     CleanupStack::Pop( self );
       
    46 
       
    47     return self;
       
    48     }
       
    49   
       
    50 CCFActivatorTimedSchedulerWait* CCFActivatorTimedSchedulerWait::NewLC()
       
    51    {
       
    52     FUNC_LOG;    
       
    53 
       
    54     CCFActivatorTimedSchedulerWait* self =
       
    55         new( ELeave ) CCFActivatorTimedSchedulerWait;
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58 
       
    59     return self;
       
    60     }
       
    61   
       
    62 CCFActivatorTimedSchedulerWait::CCFActivatorTimedSchedulerWait():
       
    63     CTimer( EPriorityStandard )
       
    64     {
       
    65     FUNC_LOG;    
       
    66 
       
    67     // Double check if base class adds active object into scheduler
       
    68     if( !IsAdded() )
       
    69         {
       
    70         CActiveScheduler::Add( this );
       
    71         }
       
    72     }
       
    73 
       
    74 void CCFActivatorTimedSchedulerWait::ConstructL()
       
    75     {
       
    76     FUNC_LOG;    
       
    77 
       
    78     // Do base constructions
       
    79     CTimer::ConstructL();
       
    80     
       
    81     // Initialize active scheduler wait
       
    82     iWait = new( ELeave ) CActiveSchedulerWait;
       
    83     }
       
    84 
       
    85 // Destructor
       
    86 CCFActivatorTimedSchedulerWait::~CCFActivatorTimedSchedulerWait()
       
    87     {
       
    88     FUNC_LOG;    
       
    89 
       
    90     Cancel();
       
    91     delete iWait;
       
    92     }
       
    93 
       
    94 // METHODS
       
    95 
       
    96 //-----------------------------------------------------------------------------
       
    97 // CCFActivatorTimedSchedulerWait::Start
       
    98 //-----------------------------------------------------------------------------
       
    99 //
       
   100 void CCFActivatorTimedSchedulerWait::Start(
       
   101     const TTimeIntervalMicroSeconds32& aInterval )
       
   102     {
       
   103     FUNC_LOG;    
       
   104 
       
   105     __ASSERT_ALWAYS( !IsActive(), Panic( EAlreadyStarted ) );
       
   106     
       
   107     After( aInterval );
       
   108     iWait->Start();
       
   109     }
       
   110 
       
   111 //-----------------------------------------------------------------------------
       
   112 // CCFActivatorTimedSchedulerWait::Stop
       
   113 //-----------------------------------------------------------------------------
       
   114 //
       
   115 void CCFActivatorTimedSchedulerWait::Stop()
       
   116     {
       
   117     FUNC_LOG;    
       
   118 
       
   119     Cancel();
       
   120     }
       
   121 
       
   122 //-----------------------------------------------------------------------------
       
   123 // CCFActivatorTimedSchedulerWait::RunL
       
   124 //-----------------------------------------------------------------------------
       
   125 //
       
   126 void CCFActivatorTimedSchedulerWait::RunL()
       
   127     {
       
   128     FUNC_LOG;    
       
   129 
       
   130     // Double check that wait really started
       
   131     if( iWait->IsStarted() )
       
   132         {
       
   133         iWait->AsyncStop();
       
   134         }
       
   135     }
       
   136 
       
   137 //-----------------------------------------------------------------------------
       
   138 // CCFActivatorTimedSchedulerWait::DoCancel
       
   139 //-----------------------------------------------------------------------------
       
   140 //
       
   141 void CCFActivatorTimedSchedulerWait::DoCancel()
       
   142     {
       
   143     FUNC_LOG;    
       
   144 
       
   145     // Double check that wait really started
       
   146     CTimer::DoCancel();
       
   147     if( iWait->IsStarted() )
       
   148         {
       
   149         iWait->AsyncStop();
       
   150         }
       
   151     }