srsf/vcommandhandler/inc/asyncworker.h
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     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 "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:  Class that is able to pause the execution until the 
       
    15 *                asynchronous call resumes it. Knows how to leave the
       
    16 *                resumed function with the error code supplied by the
       
    17 *                resuming asynchronous call
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22  
       
    23 #ifndef ASYNCWORKER_H
       
    24 #define ASYNCWORKER_H
       
    25 
       
    26 class CActiveSchedulerWait;
       
    27 
       
    28 /**
       
    29  * Is able to pause the execution until the 
       
    30  * asynchronous call resumes it. Knows how to leave the
       
    31  * resumed function with the error code supplied by the
       
    32  * resuming asynchronous call
       
    33  */
       
    34 class CAsyncWorker : public CBase 
       
    35 	{
       
    36 	public:
       
    37 		CAsyncWorker* NewLC();
       
    38 		CAsyncWorker* NewL();
       
    39 		virtual ~CAsyncWorker();
       
    40 		
       
    41 	public:
       
    42 		/**
       
    43         * Pauses the execution until StopAsyncWaitingL is called
       
    44         * Leaves if StopAsyncWaitingL is called with the negative error code
       
    45         * @leave KErrNotReady if another waiting is still in progress
       
    46         * @leave Leaves with the error code passed to StopAsyncWaitingL
       
    47         */
       
    48         void WaitForAsyncCallbackL();
       
    49         
       
    50         /** 
       
    51         * Resumes the process paused by WaitForAsyncCallbackL
       
    52         * @param aErr Result code to pass to the 
       
    53         *        WaitForAsyncCallbackL error handling. Note, that 
       
    54         *        WaitForAsyncCallbackL leaves only if aErr is negative
       
    55         * @return KErrNotReady if no waiting is in progress. Otherwise KErrNone
       
    56         */
       
    57         TInt StopAsyncWaiting( TInt aErr );
       
    58         
       
    59         /**
       
    60 		* Same as StopAsyncWaiting, but panics with AWRK <error code> instead 
       
    61 		* of returning the error code
       
    62 		* @see StopAsyncWaiting
       
    63 		*/
       
    64         void StopAsyncWaitingOrPanic( TInt aErr );
       
    65         
       
    66 	private:
       
    67 		// To pass the error code from the async callback
       
    68 		TInt	iErr;
       
    69 		
       
    70 		// Performs the waiting
       
    71 		CActiveSchedulerWait* iWaiter;
       
    72 	};
       
    73 
       
    74 #endif // ASYNCWORKER_H