diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/threadengine_8h_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/threadengine_8h_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,107 @@ + + +
+ +00001 /* +00002 * ============================================================================ +00003 * Name : CThreadEngine from CThreadEngine.h +00004 * Part of : Thread +00005 * Created : 04.02.2005 by Forum Nokia +00006 * Description: +00007 * Declares thread handling operations. Intended as an example of thread +00008 usage and synchronization between several threads. +00009 * Version : 1.0 +00010 * Copyright: Nokia Corporation +00011 * ============================================================================ +00012 */ +00013 +00014 #ifndef CTHREADENGINE_H +00015 #define CTHREADENGINE_H +00016 +00017 // INCLUDES +00018 #include "e32base.h" //CTimer +00019 #include "Threadappview.h" +00020 +00021 // CLASS DECLARATION +00022 +00026 class CThreadEngine : public CTimer +00027 { +00028 +00029 public: +00030 +00038 static CThreadEngine* NewL(CThreadAppView* aView); +00039 +00044 static CThreadEngine* NewLC(CThreadAppView* aView); +00045 +00050 ~CThreadEngine(void); +00051 +00057 void DoCancel(); +00058 +00065 void RunL(); +00066 +00073 TInt RunError(TInt aError); +00074 +00080 void StartL(); +00081 +00087 void CreateThreadsL(); +00088 +00095 static TInt ExecuteThreadOne(TAny *aPtr); +00096 +00103 static TInt ExecuteThreadTwo(TAny *aPtr); +00104 +00111 static TInt ExecuteThreadThree(TAny *aPtr); +00112 +00119 void KillThread(TInt aThreadCount); +00120 +00127 void SetSyncValue(TInt aValue); +00128 +00135 TInt GetSyncValue() const; +00136 +00137 public: //data members +00138 // Needed for synchronization +00139 RMutex iMutex; +00140 +00141 private: // Basic two-phase EPOC constructors +00142 +00148 void ConstructL(CThreadAppView* aView); +00149 +00156 CThreadEngine(void); +00157 +00158 +00159 private: // in-class methods +00160 +00168 void ThreadKilledText(const TDesC& aText, TInt aCount); +00169 +00170 private: // data members +00171 // for printing +00172 CThreadAppView* iView; +00173 +00174 // handles for threads, no need to use Open if all threads have handle connected to them. +00175 RThread iThreadOne; +00176 RThread iThreadTwo; +00177 RThread iThreadThree; +00178 +00179 // threadOne uses this to demonstrate usage of an attribute +00180 TInt iNotSynchonizedCounter; +00181 +00182 // threadOne and Two use the same variable. Synchronization is required. +00183 TInt iSynchronizedCounter; +00184 +00185 // Threads cannot be killed before they are created. True if they have been created, +00186 // false otherwise. +00187 TBool iCreatedThreads; +00188 }; +00189 +00190 #endif // CTHREADENGINE +