summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/cntsrv/inc/cactiveloop.h
blob: 9065016d4c967f8e66eec87c8b7f4c070967424e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/




#ifndef CACTIVELOOP_H
#define CACTIVELOOP_H

#include <e32base.h>

class MActiveLoopCallBack 
	{
public:
	virtual TBool DoStepL() = 0;
	virtual void  DoError(TInt aError) = 0;
	};


/**
CActiveLoop class should be used in the server for all long-running operations.
Since the server is single threaded any long running operation will effectively
block the server for all other clients. In order to avoid it, the long running
operations should be done with incremental steps. Each step should be called
from the active object and controll should be passed to the active scheduler
afterwards. 
CActiveLoop is based on CTimer in order to give the Server active object
priority on the loop operations. It is particularly necessary for Cancel of
asynchronous operation use case, where ServiceL must be called between the
steps of an incremental operation.
*/
class CActiveLoop : public CTimer
	{
public:
	void 	Register(MActiveLoopCallBack & aCallBack, TBool aUseTimer = EFalse);
	void 	RunL();
	static 	CActiveLoop* NewL();
	void 	DoCancel();
		   ~CActiveLoop();
	TInt 	RunError(TInt aError);	  
	
private:
	CActiveLoop();
	
private:	
	MActiveLoopCallBack* iCallBack;
	}; 


#endif