phonebookengines/contactsmodel/cntsrv/inc/CActiveLoop.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /**
       
     2 * Copyright (c) 2005-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CACTIVELOOP_H
       
    21 #define CACTIVELOOP_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class MActiveLoopCallBack 
       
    26 	{
       
    27 public:
       
    28 	virtual TBool DoStepL() = 0;
       
    29 	virtual void  DoError(TInt aError) = 0;
       
    30 	};
       
    31 
       
    32 
       
    33 /**
       
    34 CActiveLoop class should be used in the server for all long-running operations.
       
    35 Since the server is single threaded any long running operation will effectively
       
    36 block the server for all other clients. In order to avoid it, the long running
       
    37 operations should be done with incremental steps. Each step should be called
       
    38 from the active object and controll should be passed to the active scheduler
       
    39 afterwards. 
       
    40 CActiveLoop is based on CTimer in order to give the Server active object
       
    41 priority on the loop operations. It is particularly necessary for Cancel of
       
    42 asynchronous operation use case, where ServiceL must be called between the
       
    43 steps of an incremental operation.
       
    44 */
       
    45 class CActiveLoop : public CTimer
       
    46 	{
       
    47 public:
       
    48 	void 	Register(MActiveLoopCallBack & aCallBack, TBool aUseTimer = EFalse);
       
    49 	void 	RunL();
       
    50 	static 	CActiveLoop* NewL();
       
    51 	void 	DoCancel();
       
    52 		   ~CActiveLoop();
       
    53 	TInt 	RunError(TInt aError);	  
       
    54 	
       
    55 private:
       
    56 	CActiveLoop();
       
    57 	
       
    58 private:	
       
    59 	MActiveLoopCallBack* iCallBack;
       
    60 	}; 
       
    61 
       
    62 
       
    63 #endif