summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/threadbase.h
blob: ac2e7ad9d8f93f1574673b1f44335c8a5943006f (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
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* 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 __ThreadBase_H__
#define __ThreadBase_H__

// System includes
#if !defined(__E32MATH_H__)
#include <e32math.h> 
#endif
#if !defined(__E32TEST_H__)
#include <e32test.h>
#endif

// Constant

const TInt KMinDelay = 10000;
const TInt KMaxDelay = 50000;
const TInt KStandardTimeOut = 50000;

///////////////////////////////////////////////////////////////////////////////
/* CThreadBase - Specification                                               */
class CThreadBase : public CBase
	{
public: // user API
	CThreadBase();
	virtual ~CThreadBase();
	void Go();
	void WaitForCompetion();

public: // can be used by derived class.
	void SyncronizeSignal();
	void SyncronizeWait();
	void RandomDelay(TInt aMax, TInt aMin) const;

protected: // to be overridden by the user
	virtual void ThreadL() = 0;
	virtual const TDesC& ThreadName() const = 0;

private: // don't touch
	void DoRunThreadL();
	void SetUpTestL( const TDesC& aThreadName );
	void TakeDownTest();
	void OpenSemaphore();
	void CloseSemaphore();
	TInt RunThread();
	static TInt ThreadFunction(TAny* aMe);

public: // data
	RThread					iThread;
protected:
	RTest*					iTest;
private: // data
	RSemaphore				iSemaphoreSignal;
	RSemaphore				iSemaphoreWait;
	TBool					iSemaphoreOpen;
	CTrapCleanup* 			iCleanup;
	TRequestStatus			iThreadStatus;
	};

#endif // __ThreadBase_H__