cbsref/csyrefplugins/csy27010/src/timeouter.cpp
branchRCL_3
changeset 65 630d2f34d719
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
       
     1 //
       
     2 // * Copyright 2004 Neusoft America Inc.
       
     3 // * All rights reserved.
       
     4 // * This component and the accompanying materials are made available
       
     5 // * under the terms of the 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 // * Contributors:
       
    10 // * Keith Collins (Neusoft America Inc.)  original software development and additional code and modifications.
       
    11 // * Thomas Gahagen (Neusoft America Inc.)  additional code and modifications.
       
    12 // * Zhen Yuan (Neusoft America Inc.)  additional code and modifications.
       
    13 // *
       
    14 // * Description:  This file contains the implementation a very simple timeout class.
       
    15 //
       
    16 
       
    17 // timeouter.cpp
       
    18 
       
    19 /** @file timeouter.cpp
       
    20  *
       
    21  */
       
    22  
       
    23 #include "timeouter.h"
       
    24 #include "CsyDebugLogger.h"
       
    25 
       
    26 
       
    27 CActiveTimeouter* CActiveTimeouter::NewL(MTimeoutObserver& aObserver)
       
    28 /**
       
    29  * 2 phase constructor. Call this function to create a new 
       
    30  * active timeouter object.
       
    31  *
       
    32  * @param aObserver reference to the Observer object
       
    33  * @return a newly created CActiveTimeouter object
       
    34  */
       
    35 	{
       
    36 	CActiveTimeouter* p = new (ELeave) CActiveTimeouter(aObserver);
       
    37 	CleanupStack::PushL(p);
       
    38 	p->ConstructL(); 
       
    39 	CleanupStack::Pop(p);
       
    40 	return p;
       
    41 	}
       
    42 
       
    43 CActiveTimeouter::~CActiveTimeouter()
       
    44 /**
       
    45  * Destructor
       
    46  */
       
    47 	{
       
    48 	Cancel();
       
    49 	}
       
    50 
       
    51 void CActiveTimeouter::Start(const TTimeIntervalMicroSeconds32& aTimeoutMs)
       
    52 /**
       
    53  * Start a timeout
       
    54  *
       
    55  * @param aTimeoutMs The timeout period in microseconds
       
    56  */
       
    57 	{
       
    58 	Stop(); //Cancel current request if there is one
       
    59 	iStatus = KRequestPending;
       
    60 	After(aTimeoutMs);
       
    61 	}
       
    62   
       
    63 void CActiveTimeouter::Stop()
       
    64 /**
       
    65  * Stop the timer (if running)
       
    66  */
       
    67 	{
       
    68 
       
    69 	if (IsActive())
       
    70 	      Cancel();
       
    71 	}
       
    72 
       
    73 CActiveTimeouter::CActiveTimeouter(MTimeoutObserver& aObserver)
       
    74 /**
       
    75  * Constructor
       
    76  *
       
    77  * @param aObserver reference to the Observer object
       
    78  */
       
    79  :	CTimer(CActive::EPriorityStandard),
       
    80 	iTheTimeoutObserver(aObserver)
       
    81 	{
       
    82 	CLASSNAMEINIT(CActiveTimeouter)
       
    83 
       
    84 	CActiveScheduler::Add(this);
       
    85 	}
       
    86 
       
    87 void CActiveTimeouter::RunL()
       
    88 /**
       
    89  * Called by the Active Scheduler when the timeout completes.
       
    90  * This function calls the TimedOut() function implemented 
       
    91  * by the observer.
       
    92  */
       
    93 	{
       
    94 	iTheTimeoutObserver.TimedOut();
       
    95 	}
       
    96