diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_thread_rendezvous_8cpp-source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_thread_rendezvous_8cpp-source.html Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,110 @@ + + +TB10.1 Example Applications: examples/Base/ThreadsAndProcesses/Rendezvous/ThreadRendezvous.cpp Source File + + + + +

examples/Base/ThreadsAndProcesses/Rendezvous/ThreadRendezvous.cpp

00001 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+00002 // All rights reserved.
+00003 // This component and the accompanying materials are made available
+00004 // under the terms of "Eclipse Public License v1.0"
+00005 // which accompanies this distribution, and is available
+00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
+00007 //
+00008 // Initial Contributors:
+00009 // Nokia Corporation - initial contribution.
+00010 //
+00011 // Contributors:
+00012 //
+00013 // Description:
+00014 // Example to demonstrate the use of Rendezvous() with threads 
+00015 //
+00016 
+00017 #include "CommonFramework.h"
+00018 #include <e32math.h>
+00019 
+00020 //
+00021 // Common literal text
+00022 //
+00023 
+00024 
+00025 _LIT(KMsgMyThreadName, "MyThread");
+00026 _LIT(KMsgStartThread, "Start thread\n");
+00027 _LIT(KMsgThreadRendezvousReached,"Thread rendezvous reached\n");
+00028 _LIT(KMsgEndOfTest,"End of test\n");
+00029 _LIT(KMsgSomethingIsWrong, "Something is wrong\n");
+00030 _LIT(KMsgCreateThreadFailed, "Create thread failed\n");
+00031 
+00032 //Define
+00033 const TInt KHeapSize = 0x2000;
+00034 
+00035 //************************************************************
+00036 // Declare Thread functions
+00037 //************************************************************
+00038 TInt MyThread(TAny* aParameter)
+00039         {
+00040                 // simulate some processing
+00041         User::After((TInt)aParameter);          
+00042                         
+00043                         // signal Rendezvous
+00044         RThread::Rendezvous(KErrNone);
+00045         
+00046                 // simulate some processing
+00047         User::After((TInt)aParameter);          
+00048         
+00049         return(KErrNone);
+00050         }
+00051 
+00052 //************************************************************
+00053 // Main example code function
+00054 //************************************************************
+00055 LOCAL_C void doExampleL()
+00056         {                                 
+00057                 // create threads to wait for
+00058         RThread thread;
+00059 
+00060                 // indicate completion status
+00061         TRequestStatus myThreadRendezvousStatus;
+00062 
+00063                 // pass 500 as the parameter to MyThread                
+00064         TInt r=thread.Create(KMsgMyThreadName, MyThread, KDefaultStackSize, KHeapSize,KHeapSize,(TAny*) 2000000, EOwnerThread); 
+00065         if (r!=KErrNone)
+00066                 {       
+00067                 console->Printf(KMsgCreateThreadFailed);
+00068                 return;
+00069                 }
+00070                 // create rendezvous
+00071         thread.Rendezvous(myThreadRendezvousStatus);
+00072 
+00073                 //EXCECUTE THREAD!
+00074         console->Printf(KMsgStartThread);                                       
+00075         thread.Resume();
+00076 
+00077         User::WaitForRequest(myThreadRendezvousStatus);
+00078         if(myThreadRendezvousStatus==KErrNone)
+00079                 {
+00080                 console->Printf(KMsgThreadRendezvousReached);
+00081                 }
+00082                 else
+00083                 {
+00084                 console->Printf(KMsgSomethingIsWrong);  
+00085                 }       
+00086                 
+00087         thread.Close();
+00088         console->Printf(KMsgEndOfTest);         
+00089         
+00090         }
+00091 
+00092 
+00093         
+00094 
+00095 
+00096 
+00097         
+00098         
+

Generated on Thu Jan 21 10:32:57 2010 for TB10.1 Example Applications by  + +doxygen 1.5.3
+ +